From 3b9961c8a6a6b29aab30654232ea5cbe3675cd45 Mon Sep 17 00:00:00 2001 From: devZoGok Date: Sun, 31 Oct 2021 15:26:45 +0200 Subject: [PATCH] runnable build --- abstractBitmapText.cpp | 24 --------- abstractBitmapText.h | 31 ----------- abstractImage.cpp | 24 --------- abstractImage.h | 30 ----------- activeGameState.h | 5 +- button.cpp | 59 --------------------- button.h | 54 ------------------- checkbox.cpp | 36 ------------- checkbox.h | 34 ------------ gameManager.h | 6 --- listbox.cpp | 115 ----------------------------------------- listbox.h | 52 ------------------- optionsButton.cpp | 2 + slider.cpp | 72 -------------------------- slider.h | 56 -------------------- textbox.cpp | 89 ------------------------------- textbox.h | 49 ------------------ unit.cpp | 4 +- util.cpp | 4 +- 19 files changed, 9 insertions(+), 737 deletions(-) delete mode 100644 abstractBitmapText.cpp delete mode 100644 abstractBitmapText.h delete mode 100644 abstractImage.cpp delete mode 100644 abstractImage.h delete mode 100755 button.cpp delete mode 100755 button.h delete mode 100755 checkbox.cpp delete mode 100755 checkbox.h delete mode 100755 listbox.cpp delete mode 100755 listbox.h delete mode 100755 slider.cpp delete mode 100755 slider.h delete mode 100755 textbox.cpp delete mode 100755 textbox.h diff --git a/abstractBitmapText.cpp b/abstractBitmapText.cpp deleted file mode 100644 index 4e8c2b9..0000000 --- a/abstractBitmapText.cpp +++ /dev/null @@ -1,24 +0,0 @@ -#include "abstractBitmapText.h" -#include - -using namespace irr::core; -using namespace irr::video; -using namespace irr::gui; -using namespace game::core; - -namespace game{ - namespace gui{ - AbstractBitmapText::AbstractBitmapText(stringw text, vector2d pos, IGUIFont *font) { - this->text = text; - this->pos = pos; - this->font = font; - color = new SColor(255, 255, 255, 255); - } - - AbstractBitmapText::~AbstractBitmapText() {} - - void AbstractBitmapText::update() { - font->draw(text, rect(pos.X, pos.Y, pos.X + 10, pos.Y + 10), *color); - } - } -} diff --git a/abstractBitmapText.h b/abstractBitmapText.h deleted file mode 100644 index 582435e..0000000 --- a/abstractBitmapText.h +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef ABSTRACT_BITMAP_TEXT -#define ABSTRACT_BITMAP_TEXT - -#include "gameManager.h" - -namespace game{ - namespace gui{ - class AbstractBitmapText { - public: - AbstractBitmapText(irr::core::stringw, irr::core::vector2d, irr::gui::IGUIFont*); - ~AbstractBitmapText(); - void update(); - inline irr::core::vector2d getPos(){return pos;} - inline void setPos(irr::core::vector2d p){this->pos=p;} - inline irr::video::SColor* getColor(){return color;} - inline void setColor(irr::video::SColor *c){this->color=c;} - inline irr::core::stringw getText(){return text;} - inline void setText(irr::core::stringw t){this->text=t;} - inline irr::gui::IGUIFont* getFont(){return font;} - inline void setFont(irr::gui::IGUIFont *f){this->font=f;} - private: - core::GameManager *gameManager; - irr::core::stringw text; - irr::gui::IGUIFont *font; - irr::core::vector2d pos; - irr::video::SColor *color; - }; - } -} - -#endif diff --git a/abstractImage.cpp b/abstractImage.cpp deleted file mode 100644 index 75ede9c..0000000 --- a/abstractImage.cpp +++ /dev/null @@ -1,24 +0,0 @@ -#include "abstractImage.h" - -using namespace irr::video; -using namespace irr::core; -using namespace game::core; - -namespace game -{ - namespace gui{ - AbstractImage::AbstractImage(ITexture *image, vector2d pos, vector2d size) { - this->image = image; - this->pos = pos; - this->size = size; - } - - AbstractImage::~AbstractImage() { - } - - void AbstractImage::update() { - irr::video::IVideoDriver *driver = GameManager::getSingleton()->getDevice()->getVideoDriver(); - driver->draw2DImage(image, pos); - } - } -} diff --git a/abstractImage.h b/abstractImage.h deleted file mode 100644 index d8d21b4..0000000 --- a/abstractImage.h +++ /dev/null @@ -1,30 +0,0 @@ -#ifndef ABSTRACT_IMAGE -#define ABSTRACT_IMAGE - -#include "gameManager.h" -#include "util.h" - -namespace game -{ - namespace gui{ - class AbstractImage { - public: - AbstractImage(irr::video::ITexture*, irr::core::vector2d, irr::core::vector2d); - ~AbstractImage(); - void update(); - inline irr::video::ITexture* getImage(){return image;} - inline void setImage(irr::video::ITexture *t){this->image=t;} - inline irr::core::vector2d getPos(){return pos;} - inline irr::core::vector2d getSize(){return size;} - inline void setPos(irr::core::vector2d p){this->pos=p;} - inline void setSize(irr::core::vector2d s){this->size=s;} - inline irr::core::stringw getPath(){return path;} - private: - irr::video::ITexture *image; - irr::core::vector2d pos, size; - irr::core::stringw path; - }; - } -} - -#endif diff --git a/activeGameState.h b/activeGameState.h index 2d79ac6..10732f5 100755 --- a/activeGameState.h +++ b/activeGameState.h @@ -29,7 +29,7 @@ namespace game{ class UnitButton : public vb01Gui::Button{ public: UnitButton(ActiveGameState*, vb01::Vector2, vb01::Vector2, std::string, int, int); - ~UnitButton(); + ~UnitButton(){} virtual void onClick(); virtual void onMouseOver(); virtual void onMouseAway(); @@ -37,10 +37,11 @@ namespace game{ ActiveGameState *activeState; int faction, unitId; }; + class UnitActionButton : public vb01Gui::Button{ public: UnitActionButton(content::unitData::UNIT_TYPE, vb01::Vector2, vb01::Vector2, std::string, std::string); - ~UnitActionButton(); + ~UnitActionButton(){} virtual void onClick(); virtual void onMouseOver(); virtual void onMouseAway(); diff --git a/button.cpp b/button.cpp deleted file mode 100755 index 31ecc28..0000000 --- a/button.cpp +++ /dev/null @@ -1,59 +0,0 @@ -#include "button.h" -#include "defConfigs.h" - -using namespace irr::core; -using namespace irr::video; -using namespace irr::gui; -using namespace game::core; -using namespace game::core; - -namespace game{ - namespace gui{ - Button::Button() {} - - Button::Button(vector2d pos, vector2d size, stringw name, bool separate) { - color = new SColor(255, 200, 200, 200); - this->name = name; - this->pos = pos; - this->size = size; - this->separate = separate; - } - - Button::~Button() { - delete color; - color = nullptr; - } - - void Button::update() { - GameManager *gm = GameManager::getSingleton(); - IVideoDriver *driver = gm->getDevice()->getVideoDriver(); - - if (!imageButton) { - driver->draw2DRectangle(*color, rect(pos.X, pos.Y, pos.X + size.X, pos.Y + size.Y), nullptr); - if (separate) { - IGUIFont *font = gm->getDevice()->getGUIEnvironment()->getFont(PATH + "Fonts/fontcourier.bmp"); - font->draw(name, rect(pos.X + size.X / 4 + textXOffset, pos.Y + size.Y / 4 + textYOffset, size.X, size.Y), SColor(255, 250, 250, 250)); - } - } else - driver->draw2DImage(image->getImage(), pos); - } - - void Button::moveButton(int x, int y) { - pos.X += x; - pos.Y += y; - moveText(x, y); - } - - void Button::moveText(int x, int y) { - textXOffset += x; - textYOffset += y; - } - - void Button::setImageButton(Image *i) { - imageButton = true; - image = i; - image->setPos(pos); - size = image->getSize(); - } - } -} diff --git a/button.h b/button.h deleted file mode 100755 index bad37e4..0000000 --- a/button.h +++ /dev/null @@ -1,54 +0,0 @@ -#pragma once -#ifndef BUTTON_H -#define BUTTON_H - -#include -#include -#include "abstractImage.h" -#include "abstractBitmapText.h" -#include "gameManager.h" -#include "util.h" - -namespace game{ - namespace gui { - class Button { - public: - Button(); - Button(irr::core::vector2d, irr::core::vector2d, irr::core::stringw, bool); - ~Button(); - virtual void onClick(){} - virtual void onMouseOver(){} - virtual void onMouseAway(){} - virtual void update(); - virtual void moveText(int, int); - virtual void moveButton(int, int); - inline void setMouseOverDone(bool m){this->mouseOverDone=m;} - inline void setMouseAwayDone(bool m){this->mouseAwayDone=m;} - void setImageButton(Image*); - inline irr::core::vector2d getPos(){return pos;} - inline irr::core::vector2d getSize(){return size;} - inline void setPos(irr::core::vector2d p){this->pos=p;} - inline void setSize(irr::core::vector2d s){this->size=s;} - inline irr::video::SColor* getColor(){return color;} - inline void setColor(irr::video::SColor *c){this->color=c;} - inline irr::core::stringw getName(){return name;} - inline void setName(irr::core::stringw n){this->name=n;} - inline bool isSeparate(){return separate;} - inline bool isImageButton(){return imageButton;} - inline bool isMouseOverDone(){return mouseOverDone;} - inline bool isMouseAwayDone(){return mouseAwayDone;} - inline Image* getImage(){return image;} - private: - Image *image = nullptr; - bool separate = true, imageButton = false; - int textXOffset = 0, textYOffset = 0; - protected: - irr::core::stringw name; - irr::core::vector2d pos, size; - irr::video::SColor *color = nullptr; - bool mouseOverDone=false,mouseAwayDone=false; - }; - } -} - -#endif diff --git a/checkbox.cpp b/checkbox.cpp deleted file mode 100755 index acb1293..0000000 --- a/checkbox.cpp +++ /dev/null @@ -1,36 +0,0 @@ -#include "checkbox.h" -#include "defConfigs.h" - -using namespace irr::core; -using namespace irr::video; -using namespace game::core; - -namespace game{ - namespace gui{ - Checkbox::CheckboxButton::CheckboxButton(Checkbox *ch, vector2d pos, vector2d size, stringw name, bool separate) :Button(pos, size, name, separate) { - checkbox = ch; - } - - void Checkbox::CheckboxButton::onClick() { - checkbox->check(); - } - - Checkbox::Checkbox(vector2d pos){ - this->pos = pos; - checkboxButton = new CheckboxButton(this, pos, vector2d(length,length), "CheckboxButton", false); - } - - Checkbox::~Checkbox() { - - } - - void Checkbox::update() { - IVideoDriver *driver = GameManager::getSingleton()->getDevice()->getVideoDriver(); - driver->draw2DRectangle(SColor(255, 100, 100, 100), rect(pos.X, pos.Y, pos.X + length, pos.Y + length), nullptr); - if (checked) { - driver->draw2DLine(pos, vector2d(pos.X + length, pos.Y + length),SColor(255,255,255,255)); - driver->draw2DLine(vector2d(pos.X,pos.Y+length), vector2d(pos.X + length, pos.Y), SColor(255, 255, 255, 255)); - } - } - } -} diff --git a/checkbox.h b/checkbox.h deleted file mode 100755 index c1c3e74..0000000 --- a/checkbox.h +++ /dev/null @@ -1,34 +0,0 @@ -#pragma once -#ifndef CHECKBOX_H -#define CHECKBOX_H - -#include "button.h" - -namespace game{ - namespace gui { - class Checkbox { - public: - Checkbox(irr::core::vector2d); - ~Checkbox(); - void update(); - virtual void check(){checked=!checked;} - virtual bool isChecked(){return checked;} - private: - class CheckboxButton : public Button { - public: - CheckboxButton(Checkbox*, irr::core::vector2d, irr::core::vector2d, irr::core::stringw, bool); - void onClick(); - private: - Checkbox *checkbox = nullptr; - }; - const int length=15; - bool checked = false; - irr::core::vector2d pos; - CheckboxButton *checkboxButton; - public: - inline CheckboxButton* getCheckboxButton(){return checkboxButton;} - }; - } -} - -#endif diff --git a/gameManager.h b/gameManager.h index 899c3e2..db7b476 100755 --- a/gameManager.h +++ b/gameManager.h @@ -25,12 +25,6 @@ namespace game{ class GameManager { public: static GameManager* getSingleton(); - inline void attachBitmapText(gui::AbstractBitmapText *a){bitmapTexts.push_back(a);} - void detachBitmapText(gui::AbstractBitmapText*); - void detachAllBitmapTexts(); - inline void attachImage(gui::AbstractImage *a){images.push_back(a);} - void detachImage(gui::AbstractImage*); - void detachAllImages(); void update(); inline int getWidth(){return width;} inline int getHeight(){return height;} diff --git a/listbox.cpp b/listbox.cpp deleted file mode 100755 index fea548a..0000000 --- a/listbox.cpp +++ /dev/null @@ -1,115 +0,0 @@ -#include "listbox.h" -#include "guiAppState.h" -#include "defConfigs.h" - -using namespace game::core; -using namespace irr::core; -using namespace irr::gui; -using namespace irr::video; -using namespace std; - -namespace game{ - namespace gui{ - Listbox::ListboxButton::ListboxButton(Listbox *l, vector2d pos, vector2d size, stringw name, bool separate) : Button(pos, size, name, separate) { - listbox = l; - } - - void Listbox::ListboxButton::onClick() { - if (!listbox->isOpen()) - listbox->openUp(); - else - listbox->close(); - } - - Listbox::ScrollingButton::ScrollingButton(vector2d pos, vector2d size, stringw name, bool separate) : Button(pos, size, name, separate) { - } - - void Listbox::ScrollingButton::onClick() { - - } - - Listbox::Listbox(vector2d pos, vector2d size, vector lines, int maxDisplay, bool controlsListbox) { - this->pos = pos; - this->size = size; - this->lines = lines; - this->maxDisplay = maxDisplay; - this->controlsListbox=controlsListbox; - listboxButton = new ListboxButton(this, pos, size, "ListboxButton", false); - scrollingButton = new ScrollingButton(vector2d(pos.X + size.X - 20, pos.Y + 20), vector2d(20, 20.0 * (maxDisplay - 2) / (lines.size() - maxDisplay)), "scrollingButton", false); - } - - Listbox::~Listbox() {} - - void Listbox::update() { - GameManager *gm = GameManager::getSingleton(); - IGUIFont *font = gm->getDevice()->getGUIEnvironment()->getFont(PATH + "Fonts/fontcourier.bmp"); - - if (open) { - gm->getDevice()->getVideoDriver()->draw2DRectangle(*listboxButton->getColor(), rect(pos.X, pos.Y, pos.X + size.X, pos.Y + size.Y * maxDisplay), nullptr); - int mousePosX = gm->getDevice()->getCursorControl()->getPosition().X, mousePosY = gm->getDevice()->getCursorControl()->getPosition().Y; - - for (int i = 0; i < maxDisplay; i++) { - if (mousePosY > pos.Y + size.Y * i && mousePosY < pos.Y + size.Y * (i + 1)){ - selectedOption=scrollOffset+i; - gm->getDevice()->getVideoDriver()->draw2DRectangle(SColor(255, 200, 125, 0), rect(pos.X, pos.Y + size.Y * i, pos.X + size.X - 20, pos.Y + size.Y * (i + 1)), nullptr); - } - else if (mousePosY < pos.Y){ - selectedOption=scrollOffset; - gm->getDevice()->getVideoDriver()->draw2DRectangle(SColor(255, 200, 125, 0), rect(pos.X, pos.Y, pos.X + size.X - 20, pos.Y + size.Y), nullptr); - } - else if (mousePosY > pos.Y + size.Y * maxDisplay){ - selectedOption=scrollOffset+maxDisplay-1; - gm->getDevice()->getVideoDriver()->draw2DRectangle(SColor(255, 200, 125, 0), rect(pos.X, pos.Y + size.Y * (maxDisplay - 1), pos.X + size.X - 20, pos.Y + size.Y * (maxDisplay + 0)), nullptr); - } - } - - for (int i = 0; i < maxDisplay; i++) - font->draw(lines[i + scrollOffset], rect(pos.X, pos.Y + size.Y*i, pos.X + size.X, pos.Y + size.Y * (i + 1)), SColor(255, 255, 255, 255)); - - if (scrollOffset > 0) { - vector2d scrollingButtonPos = scrollingButton->getPos(); - scrollingButtonPos.Y = pos.Y + 20 + scrollingButton->getSize().Y * (scrollOffset - 1); - scrollingButton->setPos(scrollingButtonPos); - } - - gm->getDevice()->getVideoDriver()->draw2DRectangle(SColor(255, 150, 150, 150), rect( - scrollingButton->getPos().X, scrollingButton->getPos().Y, scrollingButton->getPos().X + scrollingButton->getSize().X, - scrollingButton->getPos().Y + scrollingButton->getSize().Y)); - } else { - gm->getDevice()->getVideoDriver()->draw2DRectangle(*listboxButton->getColor(), rect(pos.X, pos.Y, pos.X + size.X, pos.Y + size.Y), nullptr); - font->draw(lines[selectedOption], rect(pos.X, pos.Y, pos.X + size.X, pos.Y + size.Y), SColor(255, 255, 255, 255)); - } - } - - void Listbox::openUp() { - open = true; - vector2d size = listboxButton->getSize(); - size.Y *= maxDisplay; - listboxButton->setSize(size); - } - - void Listbox::close() { - if(!controlsListbox){ - open = false; - vector2d size = listboxButton->getSize(); - size.Y /= maxDisplay; - listboxButton->setSize(size); - } - } - - void Listbox::scrollUp() { - if (scrollOffset > 0) - scrollOffset--; - } - - void Listbox::scrollDown() { - if (scrollOffset < lines.size() - maxDisplay) - scrollOffset++; - } - - void Listbox::appendLines(vector& lines) { - for (int i = 0; i < this->lines.size(); i++) - lines.push_back(this->lines[i]); - } - } -} diff --git a/listbox.h b/listbox.h deleted file mode 100755 index cbe9368..0000000 --- a/listbox.h +++ /dev/null @@ -1,52 +0,0 @@ -#pragma once -#ifndef LISTBOX_H -#define LISTBOX_H - -#include "button.h" - -namespace game{ - namespace gui { - class Listbox { - public: - Listbox(irr::core::vector2d, irr::core::vector2d, std::vector, int,bool=false); - ~Listbox(); - void update(); - void openUp(); - void close(); - void scrollUp(); - void scrollDown(); - inline void addLine(irr::core::stringw l){lines.push_back(l);} - inline void changeLine(int i, irr::core::stringw l){lines[i]=l;} - inline bool isOpen(){return open;} - void appendLines(std::vector&); - inline std::vector getContents(){return lines;} - inline int getSelectedOption(){return selectedOption;} - private: - class ListboxButton : public Button { - public: - ListboxButton(Listbox*, irr::core::vector2d, irr::core::vector2d, irr::core::stringw, bool); - void onClick(); - private: - Listbox *listbox = nullptr; - }; - class ScrollingButton : public Button { - public: - ScrollingButton(irr::core::vector2d, irr::core::vector2d, irr::core::stringw, bool); - void onClick(); - private: - }; - int maxDisplay, scrollOffset = 0, selectedOption = 0; - bool open = false,controlsListbox=false; - std::vector lines; - irr::core::vector2d pos, size; - ListboxButton *listboxButton = nullptr; - Button *scrollingButton = nullptr; - public: - inline ListboxButton* getListboxButton(){return listboxButton;} - inline bool isControlsListbox(){return controlsListbox;} - inline irr::core::stringw getLine(int i){return lines[i];} - }; - } -} - -#endif diff --git a/optionsButton.cpp b/optionsButton.cpp index 3f04ded..6ad8d45 100755 --- a/optionsButton.cpp +++ b/optionsButton.cpp @@ -28,8 +28,10 @@ namespace game{ } void OptionsButton::BackButton::onClick() { GameManager *gm = GameManager::getSingleton(); + /* gm->detachAllBitmapTexts(); gm->detachAllImages(); + */ state->removeAllListboxes(); state->removeAllCheckboxes(); state->removeAllSliders(); diff --git a/slider.cpp b/slider.cpp deleted file mode 100755 index ea2256b..0000000 --- a/slider.cpp +++ /dev/null @@ -1,72 +0,0 @@ -#include -#include - -#include "slider.h" -#include "defConfigs.h" -#include "util.h" - -using namespace irr::core; -using namespace irr::video; -using namespace game::core; - -namespace game{ - namespace gui{ - Slider::MovableSliderButton::MovableSliderButton(Slider *slider, vector2d pos, vector2d size, stringw name, bool separate) : Button(pos, size, name, separate) { - this->slider = slider; - } - - void Slider::MovableSliderButton::onClick() { - clicked = !clicked; - } - - void Slider::MovableSliderButton::update() { - GameManager *gm = GameManager::getSingleton(); - int posX = gm->getDevice()->getCursorControl()->getPosition().X, posY = gm->getDevice()->getCursorControl()->getPosition().Y; - - if (clicked && posY > slider->getPos().Y && posY < slider->getPos().Y + slider->getSize().Y) { - if (posX < slider->getPos().X) - posX = slider->getPos().X; - else if (posX > slider->getPos().X + slider->getSize().X) - posX = slider->getPos().X + slider->getSize().X; - slider->setValue((((double) posX - slider->getPos().X) / slider->getSize().X) * slider->getMaxValue()); - } - } - - Slider::StaticSliderButton::StaticSliderButton(Slider *slider, vector2d pos, vector2d size, stringw name, bool separate) : Button(pos, size, name, separate) { - this->slider = slider; - } - - void Slider::StaticSliderButton::onClick() { - s16 buttonClickPoint = -slider->getPos().X + GameManager::getSingleton()->getDevice()->getCursorControl()->getPosition().X; - slider->setValue(((double) buttonClickPoint / slider->getSize().X) * slider->getMaxValue()); - } - - Slider::Slider(vector2d pos, vector2d size, double minValue, double maxValue) { - this->pos = pos; - this->size = size; - this->minValue = minValue; - this->maxValue = maxValue; - staticSliderButton = new StaticSliderButton(this, pos, size, "StaticSliderButton", false); - movableSliderButton = new MovableSliderButton(this, vector2d(pos.X + staticSliderButton->getSize().X / 1, pos.Y - 15), vector2d(10, 40), "MovableSliderButton", false); - value = (maxValue - minValue) / 2; - } - - Slider::~Slider() { - } - - void Slider::update() { - IVideoDriver *driver = GameManager::getSingleton()->getDevice()->getVideoDriver(); - - if (value < minValue) - value = minValue; - else if (value > maxValue) - value = maxValue; - movableSliderButton->update(); - driver->draw2DRectangle(*staticSliderButton->getColor(), rect(pos.X, pos.Y, pos.X + size.X, pos.Y + size.Y), nullptr); - vector2d p = movableSliderButton->getPos(), s = movableSliderButton->getSize(); - p.X = pos.X + (double) size.X / maxValue * value; - driver->draw2DRectangle(SColor(255, 200, 200, 200), rect(p.X, p.Y, p.X + s.X, p.Y + s.Y), nullptr); - movableSliderButton->setPos(p); - } - } -} diff --git a/slider.h b/slider.h deleted file mode 100755 index 175270d..0000000 --- a/slider.h +++ /dev/null @@ -1,56 +0,0 @@ -#pragma once -#ifndef SLIDER_H -#define SLIDER_H - -#include - -#include "button.h" -#include "textbox.h" - -namespace game{ - namespace gui{ - class Slider { - public: - Slider(irr::core::vector2d, irr::core::vector2d, double, double); - ~Slider(); - void update(); - inline void addTextbox(Textbox *t){this->textbox=t;} - inline double getMinValue(){return minValue;} - inline double getValue(){return value;} - inline double getMaxValue(){return maxValue;} - inline double getIncrement(){return increment;} - inline void setValue(double v){this->value=v;} - inline void setIncrement(double i){this->increment=i;} - inline irr::core::vector2d getPos(){return pos;} - inline irr::core::vector2d getSize(){return size;} - inline Textbox* getTextbox(){return textbox;} - private: - class MovableSliderButton : public Button { - public: - MovableSliderButton(Slider*, irr::core::vector2d, irr::core::vector2d, irr::core::stringw, bool); - void onClick(); - void update(); - private: - Slider *slider; - bool clicked = false; - }; - class StaticSliderButton : public Button { - public: - StaticSliderButton(Slider*, irr::core::vector2d, irr::core::vector2d, irr::core::stringw, bool); - void onClick(); - private: - Slider *slider; - }; - MovableSliderButton *movableSliderButton = nullptr; - StaticSliderButton *staticSliderButton = nullptr; - double minValue, value, maxValue, increment = .1; - irr::core::vector2d pos, size; - Textbox *textbox = nullptr; - public: - inline MovableSliderButton* getMovableSliderButton(){return movableSliderButton;} - inline StaticSliderButton* getStaticSliderButton(){return staticSliderButton;} - }; - } -} - -#endif diff --git a/textbox.cpp b/textbox.cpp deleted file mode 100755 index 4b3f6b1..0000000 --- a/textbox.cpp +++ /dev/null @@ -1,89 +0,0 @@ -#include "textbox.h" -#include "defConfigs.h" -#include "util.h" - -using namespace game::core; -using namespace game::util; -using namespace irr::core; -using namespace irr::video; - -namespace game{ - namespace gui{ - Textbox::TextboxButton::TextboxButton(Textbox *t, vector2d pos, vector2d size, stringw name, bool separate) : Button(pos, size, name, separate) { - textbox = t; - } - - void Textbox::TextboxButton::onClick() { - if (!textbox->isEnabled()) - textbox->enable(); - else - textbox->disable(); - } - - Textbox::Textbox(vector2d pos, vector2d size) { - this->pos = pos; - this->size = size; - textboxButton = new TextboxButton(this, pos, size, "TextboxButton", false); - font = GameManager::getSingleton()->getDevice()->getGUIEnvironment()->getFont(PATH + "Fonts/bigfont.png"); - } - - Textbox::~Textbox() {} - - void Textbox::update() { - GameManager *gm = GameManager::getSingleton(); - gm->getDevice()->getVideoDriver()->draw2DRectangle(SColor(255, 200, 200, 200), rect(pos.X, pos.Y, pos.X + size.X, pos.Y + size.Y), nullptr); - font->draw(entry, rect(pos.X, pos.Y - 8, pos.X + size.X, pos.Y - 8 + size.Y), SColor(255, 255, 255, 255)); - - if (enabled) { - if (canChangeCursor()) { - canShowCursor = !canShowCursor; - lastBlinkTime = getTime(); - } - if (canShowCursor) - gm->getDevice()->getVideoDriver()->draw2DRectangle(SColor(255, 100, 100, 100), rect(pos.X + 20 * (entry.size() - cursorPosOffset), pos.Y, pos.X + 4 + 20 * (entry.size() - cursorPosOffset), pos.Y + size.Y), nullptr); - } - } - - void Textbox::type(wchar_t ch) { - if (!capitalLeters) - ch = tolower(ch); - else - ch = toupper(ch); - std::vector v; - for (int i = 0; i < entry.size(); i++) - v.push_back(entry[i]); - v.insert(v.end() - cursorPosOffset, ch); - entry += 0; - for (int i = 0; i < v.size(); i++) - entry[i] = v[i]; - } - - void Textbox::moveCursor(bool left) { - if (left && entry.size() - cursorPosOffset > 0) - cursorPosOffset++; - else if (!left && cursorPosOffset > 0) - cursorPosOffset--; - } - - void Textbox::deleteCharacter() { - if (cursorPosOffset != entry.size()) { - std::vector v; - for (int i = 0; i < entry.size(); i++) - v.push_back(entry[i]); - v.erase(v.end() - 1 - cursorPosOffset); - entry.erase(entry.size() - 1); - for (int i = 0; i < v.size(); i++) - entry[i] = v[i]; - } - } - - void Textbox::enable() { - enabled = true; - lastBlinkTime = getTime(); - } - - void Textbox::disable() { - enabled = false; - } - } -} diff --git a/textbox.h b/textbox.h deleted file mode 100755 index e6f167a..0000000 --- a/textbox.h +++ /dev/null @@ -1,49 +0,0 @@ -#pragma once -#ifndef TEXTBOX_H -#define TEXTBOX_H - -#include - -#include "button.h" - -namespace game{ - namespace gui { - class Textbox { - public: - Textbox(irr::core::vector2d, irr::core::vector2d); - ~Textbox(); - void update(); - void enable(); - void disable(); - void type(wchar_t); - void moveCursor(bool); - void deleteCharacter(); - virtual irr::core::stringw getEntry(){return entry;} - virtual void setEntry(irr::core::stringw e){this->entry=e;} - virtual bool isEnabled(){return enabled;} - virtual bool isCapitalLeters(){return capitalLeters;} - virtual void setIsCapitalLeters(bool c){this->capitalLeters=c;} - virtual void setFont(irr::gui::IGUIFont *f){this->font=f;} - private: - class TextboxButton : public Button { - public: - TextboxButton(Textbox*, irr::core::vector2d, irr::core::vector2d, irr::core::stringw, bool); - void onClick(); - private: - Textbox *textbox; - }; - - irr::gui::IGUIFont *font; - irr::core::vector2d pos, size; - irr::core::stringw entry = ""; - virtual bool canChangeCursor(){return util::getTime() - lastBlinkTime > 250;} - bool enabled, canShowCursor = false, capitalLeters = false; - TextboxButton *textboxButton; - s64 lastBlinkTime, cursorPosOffset = 0; - public: - inline TextboxButton* getTextboxButton(){return textboxButton;} - }; - } -} - -#endif diff --git a/unit.cpp b/unit.cpp index 5f136d9..862a496 100755 --- a/unit.cpp +++ b/unit.cpp @@ -172,8 +172,8 @@ namespace game{ } */ - /* void Unit::debug() { + /* IVideoDriver *driver = GameManager::getSingleton()->getDevice()->getVideoDriver(); driver->setTransform(ETS_WORLD, IdentityMatrix); driver->setMaterial(createLineMaterial()); @@ -181,8 +181,8 @@ namespace game{ driver->draw3DLine(pos, pos + dirVec * length, SColor(255, 0, 0, 255)); driver->draw3DLine(pos, pos + leftVec * length, SColor(255, 255, 0, 0)); driver->draw3DLine(pos, pos + upVec * length, SColor(255, 0, 255, 0)); - } */ + } void Unit::executeOrders() { if (orders.size() > 0) { diff --git a/util.cpp b/util.cpp index d69fa15..ccc9ee1 100755 --- a/util.cpp +++ b/util.cpp @@ -40,7 +40,7 @@ namespace game{ void onClick() { GameManager *gm = GameManager::getSingleton(); - gm->detachAllBitmapTexts(); + //gm->detachAllBitmapTexts(); state->removeButton("Back"); // gameManager->dettachState(state); std::vector difficulties, factions; @@ -77,7 +77,7 @@ namespace game{ state->removeAllListboxes(); state->removeAllSliders(); state->removeAllTextboxes(); - GameManager::getSingleton()->detachAllBitmapTexts(); + //GameManager::getSingleton()->detachAllBitmapTexts(); makeTitlescreenButtons(state); state->removeButton("Play"); state->removeButton("Back");