ok, wasn't sure how explain question in title trying achieve "command line"-esque gui using allegro. graphics work fine method of keeping history isn't working obvious reasons. i'm using map store values stupid of me begin with. every time add command history same previous history, previous 1 disappears. want know is, there way can store values in way won't over-written in map?
here current method
i have struct called point
struct point { float x, y; point() { this->x = 10.0; this->y = 440.0; } point(float x, float y): x(x), y(y) { }; };
i use store points text displayed used graphics handling part of program.
this historymanager class defined in historymanager.h
class historymanager { public: historymanager(); ~historymanager(); bool firstentry; map<string, point> history; void add_to_history(string); private: void update(); };
and here defenitions in historymanager.cpp
historymanager::historymanager() { this->firstentry = false; } historymanager::~historymanager() { } void historymanager::add_to_history(string input) { if (!this->firstentry) { this->history[input] = point(10.0, 440.0); this->firstentry = true; } else { this->update(); this->history[input] = point(10.0, 440.0); } } void historymanager::update() { (map<string, point>::iterator = this->history.begin(); != this->history.end(); i++) { this->history[(*i).first] = point((*i).second.x, (*i).second.y-10.0); } }
i assume vectors option there way of pairing values together?
use std::pair
std::vector< std::pair <std::string, point> > >
or declare own struct
struct historyentry { std::string input; point point; }; std::vector<historyentry>
Comments
Post a Comment