diff options
| author | jacob1 <jfu614@gmail.com> | 2013-05-17 16:44:25 (GMT) |
|---|---|---|
| committer | jacob1 <jfu614@gmail.com> | 2013-05-17 16:44:25 (GMT) |
| commit | 981f6984c2c0f87d54a9c90f4518c69c9ef02ae0 (patch) | |
| tree | 757bd699a23c1fad61e60700265a25feb1a3042c /src/gui | |
| parent | cbd402d8cb6aa699ffde83a1b5b3c2f4fc51baaf (diff) | |
| parent | 77bf649fb4482c86ac1fd9b3233f062b53226007 (diff) | |
| download | powder-981f6984c2c0f87d54a9c90f4518c69c9ef02ae0.zip powder-981f6984c2c0f87d54a9c90f4518c69c9ef02ae0.tar.gz | |
Merge branch 'HEAD' of git@github.com:FacialTurd/The-Powder-Toy.git
Diffstat (limited to 'src/gui')
27 files changed, 186 insertions, 169 deletions
diff --git a/src/gui/dialogues/LegacyDialogues.h b/src/gui/dialogues/LegacyDialogues.h index 7f6097d..a604905 100644 --- a/src/gui/dialogues/LegacyDialogues.h +++ b/src/gui/dialogues/LegacyDialogues.h @@ -8,4 +8,4 @@ void ErrorUI(std::string title, std::string message) {} void InformationUI(std::string title, std::string message) {} -std::string MessagePromptUI(std::string title, std::string message, std::string text, std::string placeholder) {}
\ No newline at end of file +std::string MessagePromptUI(std::string title, std::string message, std::string text, std::string placeholder) {} diff --git a/src/gui/filebrowser/FileBrowserActivity.cpp b/src/gui/filebrowser/FileBrowserActivity.cpp index 7612ae2..d27f1b1 100644 --- a/src/gui/filebrowser/FileBrowserActivity.cpp +++ b/src/gui/filebrowser/FileBrowserActivity.cpp @@ -333,4 +333,4 @@ FileBrowserActivity::~FileBrowserActivity() { if(callback) delete callback; -}
\ No newline at end of file +} diff --git a/src/gui/filebrowser/FileBrowserActivity.h b/src/gui/filebrowser/FileBrowserActivity.h index d607d49..3696ba7 100644 --- a/src/gui/filebrowser/FileBrowserActivity.h +++ b/src/gui/filebrowser/FileBrowserActivity.h @@ -62,4 +62,4 @@ public: virtual void NotifyError(Task * task); virtual void NotifyProgress(Task * task); virtual void NotifyStatus(Task * task); -};
\ No newline at end of file +}; diff --git a/src/gui/game/EllipseBrush.h b/src/gui/game/EllipseBrush.h index ad28766..a71b107 100644 --- a/src/gui/game/EllipseBrush.h +++ b/src/gui/game/EllipseBrush.h @@ -29,10 +29,10 @@ public: } else { - int yTop = ry, yBottom, i, j; + int yTop = ry+1, yBottom, i, j; for (i = 0; i <= rx; i++) { - while (pow(i-rx,2.0f)*pow(ry,2.0f) + pow(yTop-ry,2.0f)*pow(rx,2.0f) <= pow(rx,2.0f)*pow(ry,2.0f)) + while (pow(i-rx,2.0)*pow(ry,2.0) + pow(yTop-ry,2.0)*pow(rx,2.0) <= pow(rx,2.0)*pow(ry,2.0)) yTop++; yBottom = 2*ry - yTop; for (int j = 0; j <= ry*2; j++) diff --git a/src/gui/game/GameController.cpp b/src/gui/game/GameController.cpp index ed1a866..d8ff3c6 100644 --- a/src/gui/game/GameController.cpp +++ b/src/gui/game/GameController.cpp @@ -145,8 +145,12 @@ GameController::GameController(): gameView->AttachController(this); gameModel->AddObserver(gameView); - commandInterface = new LuaScriptInterface(this, gameModel);//new TPTScriptInterface(); +#ifdef LUACONSOLE + commandInterface = new LuaScriptInterface(this, gameModel); ((LuaScriptInterface*)commandInterface)->SetWindow(gameView); +#else + commandInterface = new TPTScriptInterface(this, gameModel); +#endif commandInterface->OnBrushChanged(gameModel->GetBrushID(), gameModel->GetBrush()->GetRadius().X, gameModel->GetBrush()->GetRadius().X); ActiveToolChanged(0, gameModel->GetActiveTool(0)); @@ -505,17 +509,20 @@ void GameController::ToolClick(int toolSelection, ui::Point point) activeTool->Click(sim, cBrush, point); } -void GameController::StampRegion(ui::Point point1, ui::Point point2) +std::string GameController::StampRegion(ui::Point point1, ui::Point point2) { GameSave * newSave; newSave = gameModel->GetSimulation()->Save(point1.X, point1.Y, point2.X, point2.Y); if(newSave) { newSave->paused = gameModel->GetPaused(); - gameModel->AddStamp(newSave); + return gameModel->AddStamp(newSave); } else + { new ErrorMessage("Could not create stamp", "Error generating save file"); + return ""; + } } void GameController::CopyRegion(ui::Point point1, ui::Point point2) @@ -706,7 +713,9 @@ void GameController::Tick() { if(firstTick) { +#ifdef LUACONSOLE ((LuaScriptInterface*)commandInterface)->Init(); +#endif if(!Client::Ref().GetPrefBool("InstallCheck", false)) { Client::Ref().SetPref("InstallCheck", true); @@ -734,7 +743,7 @@ void GameController::ResetAir() sim->air->Clear(); for (int i = 0; i < NPART; i++) { - if (sim->parts[i].type == PT_QRTZ || sim->parts[i].type == PT_GLAS || sim->parts[i].type == PT_TUGN) + if (sim->parts[i].type == PT_QRTZ || sim->parts[i].type == PT_GLAS || sim->parts[i].type == PT_TUNG) { sim->parts[i].pavg[0] = sim->parts[i].pavg[1] = 0; } @@ -918,6 +927,11 @@ void GameController::SetHudEnable(bool hudState) gameView->SetHudEnable(hudState); } +bool GameController::GetHudEnable() +{ + return gameView->GetHudEnable(); +} + void GameController::SetActiveColourPreset(int preset) { gameModel->SetActiveColourPreset(preset); @@ -929,21 +943,19 @@ void GameController::SetColour(ui::Colour colour) gameModel->SetPresetColour(colour); } -void GameController::SetActiveMenu(Menu * menu) +void GameController::SetActiveMenu(int menuID) { - gameModel->SetActiveMenu(menu); + gameModel->SetActiveMenu(menuID); vector<Menu*> menuList = gameModel->GetMenuList(); - bool set = false; - for(int i = 0; i < menuList.size(); i++) + if(menuID == SC_DECO) + gameModel->SetColourSelectorVisibility(true); + else { - if(menuList[i]==menu && i == SC_DECO) - { - gameModel->SetColourSelectorVisibility(true); - set = true; - } - } - if(!set) gameModel->SetColourSelectorVisibility(false); + ActiveToolChanged(0, gameModel->GetActiveTool(0)); + ActiveToolChanged(1, gameModel->GetActiveTool(1)); + ActiveToolChanged(2, gameModel->GetActiveTool(2)); + } } std::vector<Menu*> GameController::GetMenuList() @@ -1036,7 +1048,7 @@ void GameController::LoadSave(SaveInfo * save) void GameController::OpenSavePreview(int saveID, int saveDate) { - activePreview = new PreviewController(saveID, new SaveOpenCallback(this)); + activePreview = new PreviewController(saveID, saveDate, new SaveOpenCallback(this)); ui::Engine::Ref().ShowWindow(activePreview->GetView()); } @@ -1300,7 +1312,7 @@ void GameController::Vote(int direction) void GameController::ChangeBrush() { - gameModel->SetBrush(gameModel->GetBrushID()+1); + gameModel->SetBrushID(gameModel->GetBrushID()+1); BrushChanged(gameModel->GetBrushID(), gameModel->GetBrush()->GetRadius().X, gameModel->GetBrush()->GetRadius().Y); } diff --git a/src/gui/game/GameController.h b/src/gui/game/GameController.h index c34d44a..b67df41 100644 --- a/src/gui/game/GameController.h +++ b/src/gui/game/GameController.h @@ -14,8 +14,11 @@ #include "gui/console/ConsoleController.h" #include "gui/localbrowser/LocalBrowserController.h" #include "gui/options/OptionsController.h" -//#include "cat/TPTScriptInterface.h" +#ifdef LUACONSOLE #include "cat/LuaScriptInterface.h" +#else +#include "cat/TPTScriptInterface.h" +#endif #include "client/ClientListener.h" #include "RenderPreset.h" #include "Menu.h" @@ -87,7 +90,7 @@ public: void DrawRect(int toolSelection, ui::Point point1, ui::Point point2); void DrawLine(int toolSelection, ui::Point point1, ui::Point point2); void DrawFill(int toolSelection, ui::Point point); - void StampRegion(ui::Point point1, ui::Point point2); + std::string StampRegion(ui::Point point1, ui::Point point2); void CopyRegion(ui::Point point1, ui::Point point2); void CutRegion(ui::Point point1, ui::Point point2); void Update(); @@ -97,7 +100,8 @@ public: void SetDecoration(); void ShowGravityGrid(); void SetHudEnable(bool hudState); - void SetActiveMenu(Menu * menu); + bool GetHudEnable(); + void SetActiveMenu(int menuID); std::vector<Menu*> GetMenuList(); void SetActiveTool(int toolSelection, Tool * tool); void ActiveToolChanged(int toolSelection, Tool *tool); diff --git a/src/gui/game/GameModel.cpp b/src/gui/game/GameModel.cpp index 1494d6d..5925079 100644 --- a/src/gui/game/GameModel.cpp +++ b/src/gui/game/GameModel.cpp @@ -3,7 +3,7 @@ #include "GameView.h" #include "simulation/Simulation.h" #include "simulation/Air.h" -#include "simulation/Tools.h" +#include "ToolClasses.h" #include "graphics/Renderer.h" #include "gui/interface/Point.h" #include "Brush.h" @@ -31,7 +31,7 @@ GameModel::GameModel(): colour(255, 0, 0, 255), toolStrength(1.0f), activeColourPreset(-1), - activeMenu(NULL), + activeMenu(-1), edgeMode(0) { sim = new Simulation(); @@ -221,9 +221,9 @@ void GameModel::BuildQuickOptionMenu(GameController * controller) void GameModel::BuildMenus() { - char lastMenu = 0; - if(activeMenu) - lastMenu = activeMenu->GetIcon(); + int lastMenu = -1; + if(activeMenu != -1) + lastMenu = activeMenu; std::string activeToolIdentifiers[3]; if(regularToolset[0]) @@ -292,7 +292,7 @@ void GameModel::BuildMenus() //Build menu for GOL types for(int i = 0; i < NGOL; i++) { - Tool * tempTool = new GolTool(i, sim->gmenu[i].name, std::string(sim->gmenu[i].description), PIXR(sim->gmenu[i].colour), PIXG(sim->gmenu[i].colour), PIXB(sim->gmenu[i].colour), "DEFAULT_PT_LIFE_"+std::string(sim->gmenu[i].name)); + Tool * tempTool = new ElementTool(PT_LIFE|(i<<8), sim->gmenu[i].name, std::string(sim->gmenu[i].description), PIXR(sim->gmenu[i].colour), PIXG(sim->gmenu[i].colour), PIXB(sim->gmenu[i].colour), "DEFAULT_PT_LIFE_"+std::string(sim->gmenu[i].name)); menuList[SC_LIFE]->AddTool(tempTool); } @@ -346,19 +346,13 @@ void GameModel::BuildMenus() lastTool = activeTools[0]; //Set default menu - activeMenu = menuList[SC_POWDERS]; + activeMenu = SC_POWDERS; - if(lastMenu) - { - for(std::vector<Menu*>::iterator iter = menuList.begin(), end = menuList.end(); iter != end; ++iter) - { - if((*iter)->GetIcon() == lastMenu) - activeMenu = *iter; - } - } + if(lastMenu != -1) + activeMenu = lastMenu; - if(activeMenu) - toolList = activeMenu->GetToolList(); + if(activeMenu != -1) + toolList = menuList[activeMenu]->GetToolList(); else toolList = std::vector<Tool*>(); @@ -424,12 +418,17 @@ Brush * GameModel::GetBrush() return brushList[currentBrush]; } +vector<Brush*> GameModel::GetBrushList() +{ + return brushList; +} + int GameModel::GetBrushID() { return currentBrush; } -void GameModel::SetBrush(int i) +void GameModel::SetBrushID(int i) { currentBrush = i%brushList.size(); notifyBrushChanged(); @@ -466,32 +465,26 @@ float GameModel::GetToolStrength() return toolStrength; } -void GameModel::SetActiveMenu(Menu * menu) +void GameModel::SetActiveMenu(int menuID) { - for(int i = 0; i < menuList.size(); i++) + activeMenu = menuID; + toolList = menuList[menuID]->GetToolList(); + notifyToolListChanged(); + + if(menuID == SC_DECO) { - if(menuList[i]==menu) + if(activeTools != decoToolset) { - activeMenu = menu; - toolList = menu->GetToolList(); - notifyToolListChanged(); - - if(menu == menuList[SC_DECO]) - { - if(activeTools != decoToolset) - { - activeTools = decoToolset; - notifyActiveToolsChanged(); - } - } - else - { - if(activeTools != regularToolset) - { - activeTools = regularToolset; - notifyActiveToolsChanged(); - } - } + activeTools = decoToolset; + notifyActiveToolsChanged(); + } + } + else + { + if(activeTools != regularToolset) + { + activeTools = regularToolset; + notifyActiveToolsChanged(); } } } @@ -506,11 +499,12 @@ vector<Tool*> GameModel::GetToolList() return toolList; } -Menu * GameModel::GetActiveMenu() +int GameModel::GetActiveMenu() { return activeMenu; } +//Get an element tool from an element ID Tool * GameModel::GetElementTool(int elementID) { #ifdef DEBUG @@ -886,12 +880,12 @@ void GameModel::SetPlaceSave(GameSave * save) notifyPlaceSaveChanged(); } -void GameModel::AddStamp(GameSave * save) +std::string GameModel::AddStamp(GameSave * save) { if(stamp) delete stamp; stamp = save; - Client::Ref().AddStamp(save); + return Client::Ref().AddStamp(save); } void GameModel::SetClipboard(GameSave * save) diff --git a/src/gui/game/GameModel.h b/src/gui/game/GameModel.h index 0ade162..92df87f 100644 --- a/src/gui/game/GameModel.h +++ b/src/gui/game/GameModel.h @@ -53,7 +53,7 @@ private: vector<Menu*> menuList; vector<QuickOption*> quickOptions; - Menu * activeMenu; + int activeMenu; int currentBrush; vector<Brush *> brushList; SaveInfo * currentSave; @@ -105,8 +105,6 @@ public: GameModel(); ~GameModel(); - Tool * GetToolFromIdentifier(std::string identifier); - void SetEdgeMode(int edgeMode); int GetEdgeMode(); @@ -136,26 +134,29 @@ public: void UpdateQuickOptions(); + Tool * GetActiveTool(int selection); + void SetActiveTool(int selection, Tool * tool); void SetToolStrength(float value); float GetToolStrength(); - Tool * GetLastTool(); void SetLastTool(Tool * newTool); + Tool * GetToolFromIdentifier(std::string identifier); + Tool * GetElementTool(int elementID); + vector<Tool*> GetToolList(); + vector<Tool*> GetUnlistedTools(); + + Brush * GetBrush(); + vector<Brush*> GetBrushList(); + int GetBrushID(); + void SetBrushID(int i); void SetVote(int direction); SaveInfo * GetSave(); SaveFile * GetSaveFile(); - Brush * GetBrush(); void SetSave(SaveInfo * newSave); void SetSaveFile(SaveFile * newSave); void AddObserver(GameView * observer); - //Get an element tool from an element ID - Tool * GetElementTool(int elementID); - - Tool * GetActiveTool(int selection); - void SetActiveTool(int selection, Tool * tool); - bool GetPaused(); void SetPaused(bool pauseState); bool GetDecoration(); @@ -166,16 +167,12 @@ public: void ShowGravityGrid(bool showGrid); void ClearSimulation(); vector<Menu*> GetMenuList(); - vector<Tool*> GetUnlistedTools(); - vector<Tool*> GetToolList(); vector<QuickOption*> GetQuickOptions(); - void SetActiveMenu(Menu * menu); - Menu * GetActiveMenu(); + void SetActiveMenu(int menuID); + int GetActiveMenu(); void FrameStep(int frames); User GetUser(); void SetUser(User user); - void SetBrush(int i); - int GetBrushID(); Simulation * GetSimulation(); Renderer * GetRenderer(); void SetZoomEnabled(bool enabled); @@ -189,7 +186,7 @@ public: void SetZoomWindowPosition(ui::Point position); ui::Point GetZoomWindowPosition(); void SetStamp(GameSave * newStamp); - void AddStamp(GameSave * save); + std::string AddStamp(GameSave * save); void SetClipboard(GameSave * save); void SetPlaceSave(GameSave * save); void Log(string message); diff --git a/src/gui/game/GameView.cpp b/src/gui/game/GameView.cpp index fcfa95c..12414c7 100644 --- a/src/gui/game/GameView.cpp +++ b/src/gui/game/GameView.cpp @@ -171,6 +171,8 @@ GameView::GameView(): infoTip(""), infoTipPresence(0), buttonTipShow(0), + isToolTipFadingIn(false), + isButtonTipFadingIn(false), toolTipPosition(-1, -1), shiftBehaviour(false), ctrlBehaviour(false), @@ -187,7 +189,7 @@ GameView::GameView(): toolTipPresence(0), currentSaveType(0), lastLogEntry(0.0f), - lastMenu(NULL) + lastMenu(-1) { int currentX = 1; @@ -401,7 +403,7 @@ GameView::GameView(): }; pauseButton = new ui::Button(ui::Point(Size.X-16, Size.Y-16), ui::Point(15, 15), "", "Pause/Resume the simulation"); //Pause pauseButton->SetIcon(IconPause); - pauseButton->SetTogglable(true); + pauseButton->SetTogglable(true); pauseButton->SetActionCallback(new PauseAction(this)); AddComponent(pauseButton); @@ -457,13 +459,13 @@ class GameView::MenuAction: public ui::ButtonAction { GameView * v; public: - Menu * menu; + int menuID; bool needsClick; - MenuAction(GameView * _v, Menu * menu_) + MenuAction(GameView * _v, int menuID_) { v = _v; - menu = menu_; - if (v->c->GetMenuList()[SC_DECO] == menu) + menuID = menuID_; + if (menuID == SC_DECO) needsClick = true; else needsClick = false; @@ -471,12 +473,12 @@ public: void MouseEnterCallback(ui::Button * sender) { if(!needsClick && !ui::Engine::Ref().GetMouseButton()) - v->c->SetActiveMenu(menu); + v->c->SetActiveMenu(menuID); } void ActionCallback(ui::Button * sender) { if (needsClick) - v->c->SetActiveMenu(menu); + v->c->SetActiveMenu(menuID); else MouseEnterCallback(sender); } @@ -564,15 +566,14 @@ void GameView::NotifyMenuListChanged(GameModel * sender) } toolButtons.clear(); vector<Menu*> menuList = sender->GetMenuList(); - for(vector<Menu*>::reverse_iterator iter = menuList.rbegin(), end = menuList.rend(); iter != end; ++iter) + for (int i = menuList.size()-1; i >= 0; i--) { std::string tempString = ""; - Menu * item = *iter; - tempString += item->GetIcon(); - ui::Button * tempButton = new ui::Button(ui::Point(XRES+BARSIZE-16, currentY), ui::Point(15, 15), tempString, item->GetDescription()); + tempString += menuList[i]->GetIcon(); + ui::Button * tempButton = new ui::Button(ui::Point(XRES+BARSIZE-16, currentY), ui::Point(15, 15), tempString, menuList[i]->GetDescription()); tempButton->Appearance.Margin = ui::Border(0, 2, 3, 2); tempButton->SetTogglable(true); - tempButton->SetActionCallback(new MenuAction(this, item)); + tempButton->SetActionCallback(new MenuAction(this, i)); currentY-=16; AddComponent(tempButton); menuButtons.push_back(tempButton); @@ -589,6 +590,11 @@ void GameView::SetHudEnable(bool hudState) showHud = hudState; } +bool GameView::GetHudEnable() +{ + return showHud; +} + ui::Point GameView::GetMousePosition() { return mousePosition; @@ -641,7 +647,7 @@ void GameView::NotifyToolListChanged(GameModel * sender) int totalColour; for(int i = 0; i < menuButtons.size(); i++) { - if(((MenuAction*)menuButtons[i]->GetActionCallback())->menu==sender->GetActiveMenu()) + if(((MenuAction*)menuButtons[i]->GetActionCallback())->menuID==sender->GetActiveMenu()) { menuButtons[i]->SetToggleState(true); } @@ -696,7 +702,7 @@ void GameView::NotifyToolListChanged(GameModel * sender) AddComponent(tempButton); toolButtons.push_back(tempButton); } - if (sender->GetActiveMenu() != sender->GetMenuList()[SC_DECO]) + if (sender->GetActiveMenu() != SC_DECO) lastMenu = sender->GetActiveMenu(); } @@ -926,7 +932,7 @@ void GameView::NotifySaveChanged(GameModel * sender) upVoteButton->Appearance.BackgroundDisabled = (ui::Colour(0, 0, 0)); upVoteButton->Appearance.BorderDisabled = ui::Colour(100, 100, 100), downVoteButton->Enabled = false; - upVoteButton->Appearance.BackgroundDisabled = (ui::Colour(0, 0, 0)); + downVoteButton->Appearance.BackgroundDisabled = (ui::Colour(0, 0, 0)); downVoteButton->Appearance.BorderDisabled = ui::Colour(100, 100, 100), tagSimulationButton->Enabled = false; tagSimulationButton->SetText("[no tags set]"); @@ -1154,8 +1160,7 @@ void GameView::ToolTip(ui::Component * sender, ui::Point mousePosition, std::str if (selectMode == PlaceSave || selectMode == SelectNone) { buttonTip = toolTip; - if (buttonTipShow < 120) - buttonTipShow += 3; + isButtonTipFadingIn = true; } } else if(sender->Position.X > Size.X-BARSIZE)// < Size.Y-(quickOptionButtons.size()+1)*16) @@ -1164,15 +1169,13 @@ void GameView::ToolTip(ui::Component * sender, ui::Point mousePosition, std::str toolTipPosition = ui::Point(Size.X-27-Graphics::textwidth((char*)toolTip.c_str()), sender->Position.Y+3); if(toolTipPosition.Y+10 > Size.Y-MENUSIZE) toolTipPosition = ui::Point(Size.X-27-Graphics::textwidth((char*)toolTip.c_str()), Size.Y-MENUSIZE-10); - if (toolTipPresence < 120) - toolTipPresence += 3; + isToolTipFadingIn = true; } else { this->toolTip = toolTip; toolTipPosition = ui::Point(Size.X-27-Graphics::textwidth((char*)toolTip.c_str()), Size.Y-MENUSIZE-10); - if (toolTipPresence < 160) - toolTipPresence += 3; + isToolTipFadingIn = true; } } @@ -1365,7 +1368,7 @@ void GameView::OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool { c->SetDecoration(true); c->SetPaused(true); - c->SetActiveMenu(c->GetMenuList()[SC_DECO]); + c->SetActiveMenu(SC_DECO); } break; case 'y': @@ -1526,15 +1529,33 @@ void GameView::OnTick(float dt) if(infoTipPresence<0) infoTipPresence = 0; } - if (selectMode != PlaceSave && selectMode != SelectNone && buttonTipShow < 120) - buttonTipShow += 2; + if (isButtonTipFadingIn || (selectMode != PlaceSave && selectMode != SelectNone)) + { + isButtonTipFadingIn = false; + if(buttonTipShow < 120) + { + buttonTipShow += int(dt*2)>0?int(dt*2):1; + if(buttonTipShow>120) + buttonTipShow = 120; + } + } else if(buttonTipShow>0) { buttonTipShow -= int(dt)>0?int(dt):1; if(buttonTipShow<0) buttonTipShow = 0; } - if(toolTipPresence>0) + if (isToolTipFadingIn) + { + isToolTipFadingIn = false; + if(toolTipPresence < 120) + { + toolTipPresence += int(dt*2)>0?int(dt*2):1; + if(toolTipPresence>120) + toolTipPresence = 120; + } + } + else if(toolTipPresence>0) { toolTipPresence -= int(dt)>0?int(dt):1; if(toolTipPresence<0) diff --git a/src/gui/game/GameView.h b/src/gui/game/GameView.h index 093d80b..328b67c 100644 --- a/src/gui/game/GameView.h +++ b/src/gui/game/GameView.h @@ -51,18 +51,20 @@ private: bool showDebug; bool wallBrush; int introText; - int buttonTipShow; - std::string buttonTip; std::string introTextMessage; int toolIndex; int currentSaveType; - Menu * lastMenu; + int lastMenu; - int infoTipPresence; + int toolTipPresence; std::string toolTip; + bool isToolTipFadingIn; ui::Point toolTipPosition; + int infoTipPresence; std::string infoTip; - int toolTipPresence; + int buttonTipShow; + std::string buttonTip; + bool isButtonTipFadingIn; queue<ui::Point> pointQueue; GameController * c; @@ -128,6 +130,7 @@ public: ui::Point GetMousePosition(); void SetSample(SimulationSample sample); void SetHudEnable(bool hudState); + bool GetHudEnable(); bool CtrlBehaviour(){ return ctrlBehaviour; } bool ShiftBehaviour(){ return shiftBehaviour; } void ExitPrompt(); diff --git a/src/gui/game/PropertyTool.cpp b/src/gui/game/PropertyTool.cpp index 05726d3..90e70b3 100644 --- a/src/gui/game/PropertyTool.cpp +++ b/src/gui/game/PropertyTool.cpp @@ -139,6 +139,11 @@ void PropertyWindow::SetProperty() buffer.exceptions(std::stringstream::failbit | std::stringstream::badbit); buffer >> tempInt; } + if (property->GetOption().first == "type" && (tempInt < 0 || tempInt >= PT_NUM || !sim->elements[tempInt].Enabled)) + { + new ErrorMessage("Could not set property", "Invalid Particle Type"); + return; + } } else { @@ -193,6 +198,7 @@ void PropertyWindow::SetProperty() break; default: new ErrorMessage("Could not set property", "Invalid property"); + return; } sim->flood_prop( position.X, @@ -232,4 +238,4 @@ void PropertyWindow::OnKeyPress(int key, Uint16 character, bool shift, bool ctrl void PropertyTool::Click(Simulation * sim, Brush * brush, ui::Point position) { new PropertyWindow(this, sim, position); -}
\ No newline at end of file +} diff --git a/src/gui/game/RenderPreset.h b/src/gui/game/RenderPreset.h index 9cc9f4c..91689c7 100644 --- a/src/gui/game/RenderPreset.h +++ b/src/gui/game/RenderPreset.h @@ -16,4 +16,4 @@ public: ColourMode(colourMode) {} }; -#endif
\ No newline at end of file +#endif diff --git a/src/gui/game/Tool.cpp b/src/gui/game/Tool.cpp index def6e46..df99e57 100644 --- a/src/gui/game/Tool.cpp +++ b/src/gui/game/Tool.cpp @@ -45,7 +45,7 @@ void Tool::DrawLine(Simulation * sim, Brush * brush, ui::Point position1, ui::Po sim->ToolLine(position1.X, position1.Y, position2.X, position2.Y, toolID, brush, strength); } void Tool::DrawRect(Simulation * sim, Brush * brush, ui::Point position1, ui::Point position2) { - sim->ToolBox(position1.X, position1.Y, position2.X, position2.Y, toolID, brush, strength); + sim->ToolBox(position1.X, position1.Y, position2.X, position2.Y, toolID, strength); } void Tool::DrawFill(Simulation * sim, Brush * brush, ui::Point position) {}; @@ -110,26 +110,6 @@ void WallTool::DrawFill(Simulation * sim, Brush * brush, ui::Point position) { sim->FloodWalls(position.X, position.Y, toolID, -1, -1, 0); } - -GolTool::GolTool(int id, string name, string description, int r, int g, int b, std::string identifier, VideoBuffer * (*textureGen)(int, int, int)): - Tool(id, name, description, r, g, b, identifier, textureGen) -{ -} -GolTool::~GolTool() {} -void GolTool::Draw(Simulation * sim, Brush * brush, ui::Point position){ - sim->CreateParts(position.X, position.Y, PT_LIFE|(toolID<<8), brush); -} -void GolTool::DrawLine(Simulation * sim, Brush * brush, ui::Point position1, ui::Point position2, bool dragging) { - sim->CreateLine(position1.X, position1.Y, position2.X, position2.Y, PT_LIFE|(toolID<<8), brush); -} -void GolTool::DrawRect(Simulation * sim, Brush * brush, ui::Point position1, ui::Point position2) { - sim->CreateBox(position1.X, position1.Y, position2.X, position2.Y, PT_LIFE|(toolID<<8), 0); -} -void GolTool::DrawFill(Simulation * sim, Brush * brush, ui::Point position) { - sim->FloodParts(position.X, position.Y, PT_LIFE|(toolID<<8), -1, -1, 0); -} - - WindTool::WindTool(int id, string name, string description, int r, int g, int b, std::string identifier, VideoBuffer * (*textureGen)(int, int, int)): Tool(id, name, description, r, g, b, identifier, textureGen) { @@ -212,4 +192,4 @@ void Element_TESC_Tool::DrawFill(Simulation * sim, Brush * brush, ui::Point posi void PlopTool::Click(Simulation * sim, Brush * brush, ui::Point position) { sim->create_part(-1, position.X, position.Y, toolID); -}
\ No newline at end of file +} diff --git a/src/gui/game/Tool.h b/src/gui/game/Tool.h index ea38fbc..df4e5cc 100644 --- a/src/gui/game/Tool.h +++ b/src/gui/game/Tool.h @@ -158,17 +158,6 @@ public: virtual void DrawFill(Simulation * sim, Brush * brush, ui::Point position); }; -class GolTool: public Tool -{ -public: - GolTool(int id, string name, string description, int r, int g, int b, std::string identifier, VideoBuffer * (*textureGen)(int, int, int) = NULL); - virtual ~GolTool(); - virtual void Draw(Simulation * sim, Brush * brush, ui::Point position); - virtual void DrawLine(Simulation * sim, Brush * brush, ui::Point position1, ui::Point position2, bool dragging = false); - virtual void DrawRect(Simulation * sim, Brush * brush, ui::Point position1, ui::Point position2); - virtual void DrawFill(Simulation * sim, Brush * brush, ui::Point position); -}; - class WindTool: public Tool { public: diff --git a/src/gui/interface/Button.cpp b/src/gui/interface/Button.cpp index 37ef22d..71ec499 100644 --- a/src/gui/interface/Button.cpp +++ b/src/gui/interface/Button.cpp @@ -153,6 +153,10 @@ void Button::OnMouseUnclick(int x, int y, unsigned int button) { if(isButtonDown) { + if(isTogglable) + { + toggle = !toggle; + } isButtonDown = false; DoAction(); } @@ -173,10 +177,6 @@ void Button::OnMouseClick(int x, int y, unsigned int button) return; if(button == 1) { - if(isTogglable) - { - toggle = !toggle; - } isButtonDown = true; } else if(button == 3) diff --git a/src/gui/interface/ContextMenu.cpp b/src/gui/interface/ContextMenu.cpp index 0d34e19..aa9eeb5 100644 --- a/src/gui/interface/ContextMenu.cpp +++ b/src/gui/interface/ContextMenu.cpp @@ -96,4 +96,4 @@ void ContextMenu::OnDraw() Graphics * g = ui::Engine::Ref().g; g->fillrect(Position.X, Position.Y, Size.X, Size.Y, 100, 100, 100, 255); g->drawrect(Position.X, Position.Y, Size.X, Size.Y, Appearance.BackgroundInactive.Red, Appearance.BackgroundInactive.Green, Appearance.BackgroundInactive.Blue, Appearance.BackgroundInactive.Alpha); -}
\ No newline at end of file +} diff --git a/src/gui/interface/ContextMenu.h b/src/gui/interface/ContextMenu.h index e5549d3..c7d8b5f 100644 --- a/src/gui/interface/ContextMenu.h +++ b/src/gui/interface/ContextMenu.h @@ -37,4 +37,4 @@ public: }; } -#endif
\ No newline at end of file +#endif diff --git a/src/gui/interface/Engine.cpp b/src/gui/interface/Engine.cpp index 6911c25..29fd5aa 100644 --- a/src/gui/interface/Engine.cpp +++ b/src/gui/interface/Engine.cpp @@ -247,7 +247,7 @@ void Engine::SetFps(float fps) { this->fps = fps; if(FpsLimit > 2.0f) - this->dt = FpsLimit/fps; + this->dt = 60/fps; else this->dt = 1.0f; } diff --git a/src/gui/interface/LuaProgressBar.h b/src/gui/interface/LuaProgressBar.h index dc2ef4e..98283cb 100644 --- a/src/gui/interface/LuaProgressBar.h +++ b/src/gui/interface/LuaProgressBar.h @@ -27,4 +27,4 @@ public: LuaProgressBar(lua_State * l); ~LuaProgressBar(); -};
\ No newline at end of file +}; diff --git a/src/gui/interface/ProgressBar.cpp b/src/gui/interface/ProgressBar.cpp index 95da72c..80eb9c6 100644 --- a/src/gui/interface/ProgressBar.cpp +++ b/src/gui/interface/ProgressBar.cpp @@ -78,4 +78,4 @@ void ProgressBar::Tick(float dt) intermediatePos += 1.0f*dt; if(intermediatePos>100.0f) intermediatePos = 0.0f; -}
\ No newline at end of file +} diff --git a/src/gui/interface/ScrollPanel.cpp b/src/gui/interface/ScrollPanel.cpp index 74f6b62..11a4f71 100644 --- a/src/gui/interface/ScrollPanel.cpp +++ b/src/gui/interface/ScrollPanel.cpp @@ -170,4 +170,4 @@ void ScrollPanel::XTick(float dt) scrollBarWidth++; else if(!mouseInside && scrollBarWidth > 0 && !scrollbarSelected) scrollBarWidth--; -}
\ No newline at end of file +} diff --git a/src/gui/interface/ScrollPanel.h b/src/gui/interface/ScrollPanel.h index c26c420..08b5069 100644 --- a/src/gui/interface/ScrollPanel.h +++ b/src/gui/interface/ScrollPanel.h @@ -29,4 +29,4 @@ namespace ui virtual void XOnMouseUp(int x, int y, unsigned int button); virtual void XOnMouseMoved(int localx, int localy, int dx, int dy); }; -}
\ No newline at end of file +} diff --git a/src/gui/render/RenderView.cpp b/src/gui/render/RenderView.cpp index 3b3a91a..8c09ceb 100644 --- a/src/gui/render/RenderView.cpp +++ b/src/gui/render/RenderView.cpp @@ -80,6 +80,7 @@ RenderView::RenderView(): ui::Window(ui::Point(0, 0), ui::Point(XRES, YRES+MENUSIZE)), toolTip(""), toolTipPresence(0), + isToolTipFadingIn(false), ren(NULL) { ui::Button * presetButton; @@ -373,6 +374,16 @@ void RenderView::OnDraw() void RenderView::OnTick(float dt) { + if (isToolTipFadingIn) + { + isToolTipFadingIn = false; + if(toolTipPresence < 120) + { + toolTipPresence += int(dt*2)>0?int(dt*2):1; + if(toolTipPresence > 120) + toolTipPresence = 0; + } + } if(toolTipPresence>0) { toolTipPresence -= int(dt)>0?int(dt):1; @@ -394,8 +405,7 @@ void RenderView::OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bo void RenderView::ToolTip(ui::Component * sender, ui::Point mousePosition, std::string toolTip) { this->toolTip = toolTip; - if (toolTipPresence < 120) - toolTipPresence += 3; + this->isToolTipFadingIn = true; } RenderView::~RenderView() { diff --git a/src/gui/render/RenderView.h b/src/gui/render/RenderView.h index 8a65eb1..4cf8cf0 100644 --- a/src/gui/render/RenderView.h +++ b/src/gui/render/RenderView.h @@ -20,6 +20,7 @@ class RenderView: public ui::Window { std::vector<ui::Checkbox*> colourModes; std::string toolTip; int toolTipPresence; + bool isToolTipFadingIn; int line1, line2, line3, line4; public: class RenderModeAction; diff --git a/src/gui/save/LocalSaveActivity.cpp b/src/gui/save/LocalSaveActivity.cpp index f494f09..084f2f2 100644 --- a/src/gui/save/LocalSaveActivity.cpp +++ b/src/gui/save/LocalSaveActivity.cpp @@ -142,4 +142,4 @@ LocalSaveActivity::~LocalSaveActivity() delete thumbnail; if(callback) delete callback; -}
\ No newline at end of file +} diff --git a/src/gui/save/LocalSaveActivity.h b/src/gui/save/LocalSaveActivity.h index b58af5e..4668dd3 100644 --- a/src/gui/save/LocalSaveActivity.h +++ b/src/gui/save/LocalSaveActivity.h @@ -36,4 +36,4 @@ public: virtual void OnDraw(); virtual void OnResponseReady(void * imagePtr); virtual ~LocalSaveActivity(); -};
\ No newline at end of file +}; diff --git a/src/gui/save/ServerSaveActivity.h b/src/gui/save/ServerSaveActivity.h index 793579b..ceca173 100644 --- a/src/gui/save/ServerSaveActivity.h +++ b/src/gui/save/ServerSaveActivity.h @@ -49,4 +49,4 @@ protected: friend class CancelAction; friend class SaveAction; friend class RulesAction; -};
\ No newline at end of file +}; |
