diff --git a/src/client/HTTP.cpp b/src/client/HTTP.cpp index ff5374697..dc1318612 100644 --- a/src/client/HTTP.cpp +++ b/src/client/HTTP.cpp @@ -936,7 +936,7 @@ retry: memset(map, 0, 62*sizeof(int)); for (i=0; names[i]; i++) { - for (unsigned int j=0; jGetCurrentCommandIndex(); - if(cIndex < consoleModel->GetPreviousCommands().size()) + size_t cIndex = consoleModel->GetCurrentCommandIndex(); + if (cIndex < consoleModel->GetPreviousCommands().size()) consoleModel->SetCurrentCommandIndex(cIndex+1); } void ConsoleController::PreviousCommand() { - int cIndex = consoleModel->GetCurrentCommandIndex(); + size_t cIndex = consoleModel->GetCurrentCommandIndex(); if(cIndex > 0) consoleModel->SetCurrentCommandIndex(cIndex-1); } diff --git a/src/gui/console/ConsoleModel.cpp b/src/gui/console/ConsoleModel.cpp index ceb6b32f4..5037703d4 100644 --- a/src/gui/console/ConsoleModel.cpp +++ b/src/gui/console/ConsoleModel.cpp @@ -19,12 +19,12 @@ void ConsoleModel::AddObserver(ConsoleView * observer) observer->NotifyPreviousCommandsChanged(this); } -int ConsoleModel::GetCurrentCommandIndex() +size_t ConsoleModel::GetCurrentCommandIndex() { return currentCommandIndex; } -void ConsoleModel::SetCurrentCommandIndex(int index) +void ConsoleModel::SetCurrentCommandIndex(size_t index) { currentCommandIndex = index; notifyCurrentCommandChanged(); @@ -55,7 +55,7 @@ std::deque ConsoleModel::GetPreviousCommands() void ConsoleModel::notifyPreviousCommandsChanged() { - for(int i = 0; i < observers.size(); i++) + for (size_t i = 0; i < observers.size(); i++) { observers[i]->NotifyPreviousCommandsChanged(this); } @@ -63,7 +63,7 @@ void ConsoleModel::notifyPreviousCommandsChanged() void ConsoleModel::notifyCurrentCommandChanged() { - for(int i = 0; i < observers.size(); i++) + for (size_t i = 0; i < observers.size(); i++) { observers[i]->NotifyCurrentCommandChanged(this); } diff --git a/src/gui/console/ConsoleModel.h b/src/gui/console/ConsoleModel.h index 312739a06..e2948498f 100644 --- a/src/gui/console/ConsoleModel.h +++ b/src/gui/console/ConsoleModel.h @@ -8,14 +8,14 @@ class ConsoleView; class ConsoleModel { - int currentCommandIndex; + size_t currentCommandIndex; std::vector observers; std::deque previousCommands; void notifyPreviousCommandsChanged(); void notifyCurrentCommandChanged(); public: - int GetCurrentCommandIndex(); - void SetCurrentCommandIndex(int index); + size_t GetCurrentCommandIndex(); + void SetCurrentCommandIndex(size_t index); ConsoleCommand GetCurrentCommand(); std::deque GetPreviousCommands(); diff --git a/src/gui/console/ConsoleView.cpp b/src/gui/console/ConsoleView.cpp index 383e0cb32..e8caefc6a 100644 --- a/src/gui/console/ConsoleView.cpp +++ b/src/gui/console/ConsoleView.cpp @@ -55,7 +55,7 @@ void ConsoleView::DoKeyPress(int key, Uint16 character, bool shift, bool ctrl, b void ConsoleView::NotifyPreviousCommandsChanged(ConsoleModel * sender) { - for(int i = 0; i < commandList.size(); i++) + for (size_t i = 0; i < commandList.size(); i++) { RemoveComponent(commandList[i]); delete commandList[i]; diff --git a/src/gui/elementsearch/ElementSearchActivity.cpp b/src/gui/elementsearch/ElementSearchActivity.cpp index f36aee85e..91d987db4 100644 --- a/src/gui/elementsearch/ElementSearchActivity.cpp +++ b/src/gui/elementsearch/ElementSearchActivity.cpp @@ -23,9 +23,9 @@ public: ElementSearchActivity::ElementSearchActivity(GameController * gameController, std::vector tools) : WindowActivity(ui::Point(-1, -1), ui::Point(236, 302)), + firstResult(NULL), gameController(gameController), tools(tools), - firstResult(NULL), exit(false) { ui::Label * title = new ui::Label(ui::Point(4, 5), ui::Point(Size.X-8, 15), "Element Search"); diff --git a/src/gui/filebrowser/FileBrowserActivity.cpp b/src/gui/filebrowser/FileBrowserActivity.cpp index ab4fa8c88..f1071c810 100644 --- a/src/gui/filebrowser/FileBrowserActivity.cpp +++ b/src/gui/filebrowser/FileBrowserActivity.cpp @@ -204,19 +204,19 @@ void FileBrowserActivity::RenameSave(SaveFile * file) void FileBrowserActivity::loadDirectory(std::string directory, std::string search) { - for(int i = 0; i < components.size(); i++) + for (size_t i = 0; i < components.size(); i++) { RemoveComponent(components[i]); itemList->RemoveChild(components[i]); } - for(std::vector::iterator iter = componentsQueue.begin(), end = componentsQueue.end(); iter != end; ++iter) + for (std::vector::iterator iter = componentsQueue.begin(), end = componentsQueue.end(); iter != end; ++iter) { delete *iter; } componentsQueue.clear(); - for(std::vector::iterator iter = files.begin(), end = files.end(); iter != end; ++iter) + for (std::vector::iterator iter = files.begin(), end = files.end(); iter != end; ++iter) { delete *iter; } @@ -239,12 +239,12 @@ void FileBrowserActivity::NotifyDone(Task * task) totalFiles = files.size(); delete loadFiles; loadFiles = NULL; - if(!files.size()) + if (!files.size()) { progressBar->Visible = false; infoText->Visible = true; } - for(int i = 0; i < components.size(); i++) + for (size_t i = 0; i < components.size(); i++) { delete components[i]; } @@ -253,7 +253,7 @@ void FileBrowserActivity::NotifyDone(Task * task) void FileBrowserActivity::OnMouseDown(int x, int y, unsigned button) { - if(!(x > Position.X && y > Position.Y && y < Position.Y+Size.Y && x < Position.X+Size.X)) //Clicked outside window + if (!(x > Position.X && y > Position.Y && y < Position.Y+Size.Y && x < Position.X+Size.X)) //Clicked outside window Exit(); } diff --git a/src/gui/game/GameController.cpp b/src/gui/game/GameController.cpp index 68853f51b..131ca70e2 100644 --- a/src/gui/game/GameController.cpp +++ b/src/gui/game/GameController.cpp @@ -119,18 +119,18 @@ public: }; GameController::GameController(): - search(NULL), - renderOptions(NULL), - loginWindow(NULL), - console(NULL), - tagsWindow(NULL), - options(NULL), - activePreview(NULL), - localBrowser(NULL), - foundSign(NULL), - HasDone(false), - firstTick(true), - debugFlags(0) + firstTick(true), + foundSign(NULL), + activePreview(NULL), + search(NULL), + renderOptions(NULL), + loginWindow(NULL), + console(NULL), + tagsWindow(NULL), + localBrowser(NULL), + options(NULL), + debugFlags(0), + HasDone(false) { gameView = new GameView(); gameModel = new GameModel(); @@ -583,7 +583,7 @@ bool GameController::MouseDown(int x, int y, unsigned button) ui::Point point = gameModel->AdjustZoomCoords(ui::Point(x, y)); x = point.X; y = point.Y; - if (gameModel->GetActiveTool(0) && gameModel->GetActiveTool(0)->GetIdentifier() != "DEFAULT_UI_SIGN" || button != BUTTON_LEFT) //If it's not a sign tool or you are right/middle clicking + if (!gameModel->GetActiveTool(0) || gameModel->GetActiveTool(0)->GetIdentifier() != "DEFAULT_UI_SIGN" || button != BUTTON_LEFT) //If it's not a sign tool or you are right/middle clicking { foundSign = GetSignAt(x, y); if(foundSign && splitsign(foundSign->text.c_str())) @@ -601,7 +601,7 @@ bool GameController::MouseUp(int x, int y, unsigned button) ui::Point point = gameModel->AdjustZoomCoords(ui::Point(x, y)); x = point.X; y = point.Y; - if (gameModel->GetActiveTool(0) && gameModel->GetActiveTool(0)->GetIdentifier() != "DEFAULT_UI_SIGN" || button != BUTTON_LEFT) //If it's not a sign tool or you are right/middle clicking + if (!gameModel->GetActiveTool(0) || gameModel->GetActiveTool(0)->GetIdentifier() != "DEFAULT_UI_SIGN" || button != BUTTON_LEFT) //If it's not a sign tool or you are right/middle clicking { sign * foundSign = GetSignAt(x, y); if(foundSign) { @@ -1455,7 +1455,7 @@ void GameController::NotifyNewNotification(Client * sender, std::pair brushFiles = Client::Ref().DirectorySearch(BRUSH_DIR, "", ".ptb"); - for(int i = 0; i < brushFiles.size(); i++) + for (size_t i = 0; i < brushFiles.size(); i++) { std::vector brushData = Client::Ref().ReadFile(brushFiles[i]); if(!brushData.size()) @@ -112,8 +110,8 @@ GameModel::GameModel(): std::cout << "Brushes: Skipping " << brushFiles[i] << ". Could not open" << std::endl; continue; } - int dimension = std::sqrt((float)brushData.size()); - if(dimension * dimension != brushData.size()) + size_t dimension = std::sqrt((float)brushData.size()); + if (dimension * dimension != brushData.size()) { std::cout << "Brushes: Skipping " << brushFiles[i] << ". Invalid bitmap size" << std::endl; continue; @@ -164,15 +162,15 @@ GameModel::~GameModel() Client::Ref().SetPref("Decoration.Blue", (int)colour.Blue); Client::Ref().SetPref("Decoration.Alpha", (int)colour.Alpha); - for(int i = 0; i < menuList.size(); i++) + for (size_t i = 0; i < menuList.size(); i++) { delete menuList[i]; } - for(std::vector::iterator iter = extraElementTools.begin(), end = extraElementTools.end(); iter != end; ++iter) + for (std::vector::iterator iter = extraElementTools.begin(), end = extraElementTools.end(); iter != end; ++iter) { delete *iter; } - for(int i = 0; i < brushList.size(); i++) + for (size_t i = 0; i < brushList.size(); i++) { delete brushList[i]; } @@ -306,7 +304,7 @@ void GameModel::BuildMenus() } //Build menu for tools - for(int i = 0; i < sim->tools.size(); i++) + for (size_t i = 0; i < sim->tools.size(); i++) { Tool * tempTool; tempTool = new Tool(i, sim->tools[i]->Name, sim->tools[i]->Description, PIXR(sim->tools[i]->Colour), PIXG(sim->tools[i]->Colour), PIXB(sim->tools[i]->Colour), sim->tools[i]->Identifier); @@ -752,10 +750,10 @@ int GameModel::GetZoomFactor() return ren->ZFACTOR; } -void GameModel::SetActiveColourPreset(int preset) +void GameModel::SetActiveColourPreset(size_t preset) { - if (activeColourPreset != preset) - activeColourPreset = preset; + if (activeColourPreset-1 != preset) + activeColourPreset = preset+1; else { activeTools[0] = GetToolFromIdentifier("DEFAULT_DECOR_SET"); @@ -764,16 +762,16 @@ void GameModel::SetActiveColourPreset(int preset) notifyColourActivePresetChanged(); } -int GameModel::GetActiveColourPreset() +size_t GameModel::GetActiveColourPreset() { - return activeColourPreset; + return activeColourPreset-1; } void GameModel::SetPresetColour(ui::Colour colour) { - if(activeColourPreset >= 0 && activeColourPreset < colourPresets.size()) + if (activeColourPreset > 0 && activeColourPreset <= colourPresets.size()) { - colourPresets[activeColourPreset] = colour; + colourPresets[activeColourPreset-1] = colour; notifyColourPresetsChanged(); } } @@ -802,7 +800,7 @@ void GameModel::SetColourSelectorColour(ui::Colour colour_) colour = colour_; vector tools = GetMenuList()[SC_DECO]->GetToolList(); - for(int i = 0; i < tools.size(); i++) + for (size_t i = 0; i < tools.size(); i++) { ((DecorationTool*)tools[i])->Red = colour.Red; ((DecorationTool*)tools[i])->Green = colour.Green; @@ -999,7 +997,7 @@ std::string GameModel::GetInfoTip() void GameModel::notifyNotificationsChanged() { - for(std::vector::iterator iter = observers.begin(); iter != observers.end(); ++iter) + for (std::vector::iterator iter = observers.begin(); iter != observers.end(); ++iter) { (*iter)->NotifyNotificationsChanged(this); } @@ -1007,7 +1005,7 @@ void GameModel::notifyNotificationsChanged() void GameModel::notifyColourPresetsChanged() { - for(std::vector::iterator iter = observers.begin(); iter != observers.end(); ++iter) + for (std::vector::iterator iter = observers.begin(); iter != observers.end(); ++iter) { (*iter)->NotifyColourPresetsChanged(this); } @@ -1015,7 +1013,7 @@ void GameModel::notifyColourPresetsChanged() void GameModel::notifyColourActivePresetChanged() { - for(std::vector::iterator iter = observers.begin(); iter != observers.end(); ++iter) + for (std::vector::iterator iter = observers.begin(); iter != observers.end(); ++iter) { (*iter)->NotifyColourActivePresetChanged(this); } @@ -1023,7 +1021,7 @@ void GameModel::notifyColourActivePresetChanged() void GameModel::notifyColourSelectorColourChanged() { - for(int i = 0; i < observers.size(); i++) + for (size_t i = 0; i < observers.size(); i++) { observers[i]->NotifyColourSelectorColourChanged(this); } @@ -1031,7 +1029,7 @@ void GameModel::notifyColourSelectorColourChanged() void GameModel::notifyColourSelectorVisibilityChanged() { - for(int i = 0; i < observers.size(); i++) + for (size_t i = 0; i < observers.size(); i++) { observers[i]->NotifyColourSelectorVisibilityChanged(this); } @@ -1039,7 +1037,7 @@ void GameModel::notifyColourSelectorVisibilityChanged() void GameModel::notifyRendererChanged() { - for(int i = 0; i < observers.size(); i++) + for (size_t i = 0; i < observers.size(); i++) { observers[i]->NotifyRendererChanged(this); } @@ -1047,7 +1045,7 @@ void GameModel::notifyRendererChanged() void GameModel::notifySaveChanged() { - for(int i = 0; i < observers.size(); i++) + for (size_t i = 0; i < observers.size(); i++) { observers[i]->NotifySaveChanged(this); } @@ -1055,7 +1053,7 @@ void GameModel::notifySaveChanged() void GameModel::notifySimulationChanged() { - for(int i = 0; i < observers.size(); i++) + for (size_t i = 0; i < observers.size(); i++) { observers[i]->NotifySimulationChanged(this); } @@ -1063,7 +1061,7 @@ void GameModel::notifySimulationChanged() void GameModel::notifyPausedChanged() { - for(int i = 0; i < observers.size(); i++) + for (size_t i = 0; i < observers.size(); i++) { observers[i]->NotifyPausedChanged(this); } @@ -1071,7 +1069,7 @@ void GameModel::notifyPausedChanged() void GameModel::notifyDecorationChanged() { - for(int i = 0; i < observers.size(); i++) + for (size_t i = 0; i < observers.size(); i++) { //observers[i]->NotifyPausedChanged(this); } @@ -1079,7 +1077,7 @@ void GameModel::notifyDecorationChanged() void GameModel::notifyBrushChanged() { - for(int i = 0; i < observers.size(); i++) + for (size_t i = 0; i < observers.size(); i++) { observers[i]->NotifyBrushChanged(this); } @@ -1087,7 +1085,7 @@ void GameModel::notifyBrushChanged() void GameModel::notifyMenuListChanged() { - for(int i = 0; i < observers.size(); i++) + for (size_t i = 0; i < observers.size(); i++) { observers[i]->NotifyMenuListChanged(this); } @@ -1095,7 +1093,7 @@ void GameModel::notifyMenuListChanged() void GameModel::notifyToolListChanged() { - for(int i = 0; i < observers.size(); i++) + for (size_t i = 0; i < observers.size(); i++) { observers[i]->NotifyToolListChanged(this); } @@ -1103,7 +1101,7 @@ void GameModel::notifyToolListChanged() void GameModel::notifyActiveToolsChanged() { - for(int i = 0; i < observers.size(); i++) + for (size_t i = 0; i < observers.size(); i++) { observers[i]->NotifyActiveToolsChanged(this); } @@ -1111,7 +1109,7 @@ void GameModel::notifyActiveToolsChanged() void GameModel::notifyUserChanged() { - for(int i = 0; i < observers.size(); i++) + for (size_t i = 0; i < observers.size(); i++) { observers[i]->NotifyUserChanged(this); } @@ -1119,7 +1117,7 @@ void GameModel::notifyUserChanged() void GameModel::notifyZoomChanged() { - for(int i = 0; i < observers.size(); i++) + for (size_t i = 0; i < observers.size(); i++) { observers[i]->NotifyZoomChanged(this); } @@ -1127,7 +1125,7 @@ void GameModel::notifyZoomChanged() void GameModel::notifyPlaceSaveChanged() { - for(int i = 0; i < observers.size(); i++) + for (size_t i = 0; i < observers.size(); i++) { observers[i]->NotifyPlaceSaveChanged(this); } @@ -1135,7 +1133,7 @@ void GameModel::notifyPlaceSaveChanged() void GameModel::notifyLogChanged(string entry) { - for(int i = 0; i < observers.size(); i++) + for (size_t i = 0; i < observers.size(); i++) { observers[i]->NotifyLogChanged(this, entry); } @@ -1143,7 +1141,7 @@ void GameModel::notifyLogChanged(string entry) void GameModel::notifyInfoTipChanged() { - for(int i = 0; i < observers.size(); i++) + for (size_t i = 0; i < observers.size(); i++) { observers[i]->NotifyInfoTipChanged(this); } @@ -1151,7 +1149,7 @@ void GameModel::notifyInfoTipChanged() void GameModel::notifyToolTipChanged() { - for(int i = 0; i < observers.size(); i++) + for (size_t i = 0; i < observers.size(); i++) { observers[i]->NotifyToolTipChanged(this); } @@ -1159,7 +1157,7 @@ void GameModel::notifyToolTipChanged() void GameModel::notifyQuickOptionsChanged() { - for(int i = 0; i < observers.size(); i++) + for (size_t i = 0; i < observers.size(); i++) { observers[i]->NotifyQuickOptionsChanged(this); } @@ -1167,7 +1165,7 @@ void GameModel::notifyQuickOptionsChanged() void GameModel::notifyLastToolChanged() { - for(int i = 0; i < observers.size(); i++) + for (size_t i = 0; i < observers.size(); i++) { observers[i]->NotifyLastToolChanged(this); } diff --git a/src/gui/game/GameModel.h b/src/gui/game/GameModel.h index 581ceab1d..6b844ec3c 100644 --- a/src/gui/game/GameModel.h +++ b/src/gui/game/GameModel.h @@ -49,6 +49,8 @@ private: //Tools that are present in elementTools, but don't have an associated menu and need to be freed manually vector extraElementTools; + Simulation * sim; + Renderer * ren; vector menuList; vector quickOptions; int activeMenu; @@ -56,8 +58,6 @@ private: vector brushList; SaveInfo * currentSave; SaveFile * currentFile; - Simulation * sim; - Renderer * ren; Tool * lastTool; Tool ** activeTools; Tool * decoToolset[4]; @@ -66,7 +66,7 @@ private: float toolStrength; std::deque history; - int activeColourPreset; + size_t activeColourPreset; std::vector colourPresets; bool colourSelector; ui::Colour colour; @@ -106,8 +106,8 @@ public: void SetEdgeMode(int edgeMode); int GetEdgeMode(); - void SetActiveColourPreset(int preset); - int GetActiveColourPreset(); + void SetActiveColourPreset(size_t preset); + size_t GetActiveColourPreset(); void SetPresetColour(ui::Colour colour); diff --git a/src/gui/game/GameView.cpp b/src/gui/game/GameView.cpp index 3e11488bc..df1f70818 100644 --- a/src/gui/game/GameView.cpp +++ b/src/gui/game/GameView.cpp @@ -41,10 +41,10 @@ private: public: SplitButton(ui::Point position, ui::Point size, std::string buttonText, std::string toolTip, std::string toolTip2, int split) : Button(position, size, buttonText, toolTip), - toolTip2(toolTip2), + showSplit(true), splitPosition(split), - splitActionCallback(NULL), - showSplit(true) + toolTip2(toolTip2), + splitActionCallback(NULL) { } @@ -150,51 +150,54 @@ public: GameView::GameView(): ui::Window(ui::Point(0, 0), ui::Point(WINDOWW, WINDOWH)), - pointQueue(queue()), isMouseDown(false), - ren(NULL), - activeBrush(NULL), - currentMouse(0, 0), - toolIndex(0), zoomEnabled(false), zoomCursorFixed(false), mouseInZoom(false), - drawPoint1(0, 0), - drawPoint2(0, 0), - drawMode(DrawPoints), - drawModeReset(false), - selectMode(SelectNone), - selectPoint1(0, 0), - selectPoint2(0, 0), - placeSaveThumb(NULL), - mousePosition(0, 0), - lastOffset(0), drawSnap(false), - toolTip(""), - infoTip(""), - infoTipPresence(0), - buttonTipShow(0), - isToolTipFadingIn(false), - isButtonTipFadingIn(false), - toolTipPosition(-1, -1), - saveSimulationButtonEnabled(false), shiftBehaviour(false), ctrlBehaviour(false), altBehaviour(false), showHud(true), showDebug(false), - introText(2048), - introTextMessage(introTextData), wallBrush(false), toolBrush(false), windTool(false), + toolIndex(0), + currentSaveType(0), + lastMenu(-1), + + toolTipPresence(0), + toolTip(""), + isToolTipFadingIn(false), + toolTipPosition(-1, -1), + infoTipPresence(0), + infoTip(""), + buttonTipShow(0), + buttonTip(""), + isButtonTipFadingIn(false), + introText(2048), + introTextMessage(introTextData), + doScreenshot(false), recording(false), screenshotIndex(0), recordingIndex(0), - toolTipPresence(0), - currentSaveType(0), - lastMenu(-1) + pointQueue(queue()), + ren(NULL), + activeBrush(NULL), + saveSimulationButtonEnabled(false), + drawMode(DrawPoints), + drawModeReset(false), + drawPoint1(0, 0), + drawPoint2(0, 0), + selectMode(SelectNone), + selectPoint1(0, 0), + selectPoint2(0, 0), + currentMouse(0, 0), + mousePosition(0, 0), + placeSaveThumb(NULL), + lastOffset(0) { int currentX = 1; @@ -513,6 +516,9 @@ public: case QuickOption::Toggle: button->SetTogglable(true); button->SetToggleState(option->GetToggle()); + break; + default: + break; } } }; @@ -536,7 +542,7 @@ public: void GameView::NotifyQuickOptionsChanged(GameModel * sender) { - for(int i = 0; i < quickOptionButtons.size(); i++) + for (size_t i = 0; i < quickOptionButtons.size(); i++) { RemoveComponent(quickOptionButtons[i]); delete quickOptionButtons[i]; @@ -562,20 +568,20 @@ void GameView::NotifyQuickOptionsChanged(GameModel * sender) void GameView::NotifyMenuListChanged(GameModel * sender) { int currentY = WINDOWH-48;//-(sender->GetMenuList().size()*16); - for(int i = 0; i < menuButtons.size(); i++) + for (size_t i = 0; i < menuButtons.size(); i++) { RemoveComponent(menuButtons[i]); delete menuButtons[i]; } menuButtons.clear(); - for(int i = 0; i < toolButtons.size(); i++) + for (size_t i = 0; i < toolButtons.size(); i++) { RemoveComponent(toolButtons[i]); delete toolButtons[i]; } toolButtons.clear(); vector menuList = sender->GetMenuList(); - for (int i = menuList.size()-1; i >= 0; i--) + for (int i = (int)menuList.size()-1; i >= 0; i--) { std::string tempString = ""; tempString += menuList[i]->GetIcon(); @@ -633,7 +639,7 @@ bool GameView::GetPlacingZoom() void GameView::NotifyActiveToolsChanged(GameModel * sender) { - for(int i = 0; i < toolButtons.size(); i++) + for (size_t i = 0; i < toolButtons.size(); i++) { Tool * tool = ((ToolAction*)toolButtons[i]->GetActionCallback())->tool; if(sender->GetActiveTool(0) == tool) @@ -685,9 +691,9 @@ void GameView::NotifyToolListChanged(GameModel * sender) { lastOffset = 0; int currentX = WINDOWW-56; - for(int i = 0; i < menuButtons.size(); i++) + for (size_t i = 0; i < menuButtons.size(); i++) { - if(((MenuAction*)menuButtons[i]->GetActionCallback())->menuID==sender->GetActiveMenu()) + if (((MenuAction*)menuButtons[i]->GetActionCallback())->menuID==sender->GetActiveMenu()) { menuButtons[i]->SetToggleState(true); } @@ -696,14 +702,14 @@ void GameView::NotifyToolListChanged(GameModel * sender) menuButtons[i]->SetToggleState(false); } } - for(int i = 0; i < toolButtons.size(); i++) + for (size_t i = 0; i < toolButtons.size(); i++) { RemoveComponent(toolButtons[i]); delete toolButtons[i]; } toolButtons.clear(); vector toolList = sender->GetToolList(); - for(int i = 0; i < toolList.size(); i++) + for (size_t i = 0; i < toolList.size(); i++) { VideoBuffer * tempTexture = toolList[i]->GetTexture(26, 14); ToolButton * tempButton; @@ -823,9 +829,9 @@ void GameView::NotifyColourPresetsChanged(GameModel * sender) void GameView::NotifyColourActivePresetChanged(GameModel * sender) { - for(int i = 0; i < colourPresets.size(); i++) + for (size_t i = 0; i < colourPresets.size(); i++) { - if(sender->GetActiveColourPreset() == i) + if (sender->GetActiveColourPreset() == i) { colourPresets[i]->SetSelectionState(0); //Primary } diff --git a/src/gui/game/GameView.h b/src/gui/game/GameView.h index 80a58f54d..d67a5addc 100644 --- a/src/gui/game/GameView.h +++ b/src/gui/game/GameView.h @@ -33,13 +33,6 @@ class GameModel; class GameView: public ui::Window { private: - DrawMode drawMode; - - bool doScreenshot; - bool recording; - int screenshotIndex; - int recordingIndex; - bool isMouseDown; bool zoomEnabled; bool zoomCursorFixed; @@ -53,8 +46,6 @@ private: bool wallBrush; bool toolBrush; bool windTool; - int introText; - std::string introTextMessage; int toolIndex; int currentSaveType; int lastMenu; @@ -68,6 +59,13 @@ private: int buttonTipShow; std::string buttonTip; bool isButtonTipFadingIn; + int introText; + std::string introTextMessage; + + bool doScreenshot; + bool recording; + int screenshotIndex; + int recordingIndex; queue pointQueue; GameController * c; @@ -92,11 +90,11 @@ private: ui::Button * simulationOptionButton; ui::Button * displayModeButton; ui::Button * pauseButton; - ui::Point currentMouse; ui::Button * colourPicker; vector colourPresets; + DrawMode drawMode; bool drawModeReset; ui::Point drawPoint1; ui::Point drawPoint2; @@ -105,6 +103,7 @@ private: ui::Point selectPoint1; ui::Point selectPoint2; + ui::Point currentMouse; ui::Point mousePosition; VideoBuffer * placeSaveThumb; diff --git a/src/gui/game/PropertyTool.cpp b/src/gui/game/PropertyTool.cpp index 72d085750..c1aba195f 100644 --- a/src/gui/game/PropertyTool.cpp +++ b/src/gui/game/PropertyTool.cpp @@ -76,7 +76,7 @@ sim(sim_) property = new ui::DropDown(ui::Point(8, 25), ui::Point(Size.X-16, 17)); property->SetActionCallback(new PropertyChanged(this)); AddComponent(property); - for(int i = 0; i < properties.size(); i++) + for (size_t i = 0; i < properties.size(); i++) { property->AddOption(std::pair(properties[i].Name, i)); } diff --git a/src/gui/game/SignTool.cpp b/src/gui/game/SignTool.cpp index 133b2d95c..e17d4d81e 100644 --- a/src/gui/game/SignTool.cpp +++ b/src/gui/game/SignTool.cpp @@ -101,11 +101,11 @@ public: SignWindow::SignWindow(SignTool * tool_, Simulation * sim_, int signID_, ui::Point position_): ui::Window(ui::Point(-1, -1), ui::Point(200, 87)), tool(tool_), - signID(signID_), - sim(sim_), - signPosition(position_), movingSign(NULL), - signMoving(false) + signMoving(false), + sim(sim_), + signID(signID_), + signPosition(position_) { ui::Label * messageLabel = new ui::Label(ui::Point(4, 5), ui::Point(Size.X-8, 15), "New sign"); messageLabel->SetTextColour(style::Colour::InformationTitle); @@ -271,9 +271,10 @@ VideoBuffer * SignTool::GetIcon(int toolID, int width, int height) void SignTool::Click(Simulation * sim, Brush * brush, ui::Point position) { int signX, signY, signW, signH, signIndex = -1; - for(int i = 0; i < sim->signs.size(); i++){ + for (size_t i = 0; i < sim->signs.size(); i++) + { sim->signs[i].pos(sim->signs[i].getText(sim), signX, signY, signW, signH); - if(position.X > signX && position.X < signX+signW && position.Y > signY && position.Y < signY+signH) + if (position.X > signX && position.X < signX+signW && position.Y > signY && position.Y < signY+signH) { signIndex = i; break; diff --git a/src/gui/game/Tool.cpp b/src/gui/game/Tool.cpp index b0def6c79..76fedaea8 100644 --- a/src/gui/game/Tool.cpp +++ b/src/gui/game/Tool.cpp @@ -7,16 +7,16 @@ using namespace std; Tool::Tool(int id, string name, string description, int r, int g, int b, std::string identifier, VideoBuffer * (*textureGen)(int, int, int)): + textureGen(textureGen), toolID(id), toolName(name), toolDescription(description), - colRed(r), - colGreen(g), - colBlue(b), - textureGen(textureGen), strength(1.0f), resolution(1), - identifier(identifier) + identifier(identifier), + colRed(r), + colGreen(g), + colBlue(b) { } diff --git a/src/gui/game/Tool.h b/src/gui/game/Tool.h index 76988da19..8d508f91d 100644 --- a/src/gui/game/Tool.h +++ b/src/gui/game/Tool.h @@ -23,6 +23,8 @@ protected: int resolution; std::string identifier; public: + int colRed, colGreen, colBlue; + Tool(int id, string name, string description, int r, int g, int b, std::string identifier, VideoBuffer * (*textureGen)(int, int, int) = NULL); int GetToolID() { return toolID; } string GetName(); @@ -39,7 +41,6 @@ public: 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); - int colRed, colBlue, colGreen; }; class GameModel; diff --git a/src/gui/interface/Appearance.cpp b/src/gui/interface/Appearance.cpp index a4c21d024..d4b6c93e8 100644 --- a/src/gui/interface/Appearance.cpp +++ b/src/gui/interface/Appearance.cpp @@ -4,8 +4,10 @@ namespace ui { Appearance::Appearance(): - HorizontalAlign(AlignCentre), + texture(NULL), + VerticalAlign(AlignMiddle), + HorizontalAlign(AlignCentre), BackgroundHover(20, 20, 20), BackgroundInactive(0, 0, 0), @@ -25,10 +27,8 @@ namespace ui Margin(1, 4), Border(1), - icon(NoIcon), - - texture(NULL) - {}; + icon(NoIcon) + {} VideoBuffer * Appearance::GetTexture() { diff --git a/src/gui/interface/AvatarButton.cpp b/src/gui/interface/AvatarButton.cpp index 9176964f3..1469cf663 100644 --- a/src/gui/interface/AvatarButton.cpp +++ b/src/gui/interface/AvatarButton.cpp @@ -14,10 +14,10 @@ namespace ui { AvatarButton::AvatarButton(Point position, Point size, std::string username): Component(position, size), - name(username), - actionCallback(NULL), avatar(NULL), - tried(false) + name(username), + tried(false), + actionCallback(NULL) { } diff --git a/src/gui/interface/Button.cpp b/src/gui/interface/Button.cpp index 3c5dd7c81..eb22ed971 100644 --- a/src/gui/interface/Button.cpp +++ b/src/gui/interface/Button.cpp @@ -8,14 +8,14 @@ namespace ui { Button::Button(Point position, Point size, std::string buttonText, std::string toolTip): Component(position, size), + Enabled(true), ButtonText(buttonText), - isMouseInside(false), + toolTip(toolTip), isButtonDown(false), + isMouseInside(false), isTogglable(false), toggle(false), - actionCallback(NULL), - Enabled(true), - toolTip(toolTip) + actionCallback(NULL) { TextPosition(); } diff --git a/src/gui/interface/Button.h b/src/gui/interface/Button.h index b31ff8779..f115c3639 100644 --- a/src/gui/interface/Button.h +++ b/src/gui/interface/Button.h @@ -24,7 +24,6 @@ public: Button(Point position = Point(0, 0), Point size = Point(0, 0), std::string buttonText = "", std::string toolTip = ""); virtual ~Button(); - bool Toggleable; bool Enabled; virtual void OnMouseClick(int x, int y, unsigned int button); @@ -53,9 +52,9 @@ public: void SetToolTip(std::string newToolTip) { toolTip = newToolTip; } protected: + std::string ButtonText; std::string toolTip; std::string buttonDisplayText; - std::string ButtonText; bool isButtonDown, isAltButtonDown, state, isMouseInside, isTogglable, toggle; ButtonAction * actionCallback; diff --git a/src/gui/interface/Checkbox.cpp b/src/gui/interface/Checkbox.cpp index d2a59191e..ee7198524 100644 --- a/src/gui/interface/Checkbox.cpp +++ b/src/gui/interface/Checkbox.cpp @@ -6,8 +6,8 @@ Checkbox::Checkbox(ui::Point position, ui::Point size, std::string text, std::st Component(position, size), text(text), toolTip(toolTip), - isMouseOver(false), checked(false), + isMouseOver(false), actionCallback(NULL) { diff --git a/src/gui/interface/Component.cpp b/src/gui/interface/Component.cpp index 6c4c54846..380ee4e94 100644 --- a/src/gui/interface/Component.cpp +++ b/src/gui/interface/Component.cpp @@ -12,15 +12,15 @@ using namespace ui; Component::Component(Window* parent_state): parentstate_(parent_state), _parent(NULL), - Position(Point(0,0)), - Size(Point(0,0)), - Locked(false), - Visible(true), + drawn(false), textPosition(0, 0), textSize(0, 0), iconPosition(0, 0), - drawn(false), - menu(NULL) + menu(NULL), + Position(Point(0,0)), + Size(Point(0,0)), + Locked(false), + Visible(true) { } @@ -28,15 +28,15 @@ Component::Component(Window* parent_state): Component::Component(Point position, Point size): parentstate_(0), _parent(NULL), - Position(position), - Size(size), - Locked(false), - Visible(true), + drawn(false), textPosition(0, 0), textSize(0, 0), iconPosition(0, 0), - drawn(false), - menu(NULL) + menu(NULL), + Position(position), + Size(size), + Locked(false), + Visible(true) { } @@ -44,15 +44,15 @@ Component::Component(Point position, Point size): Component::Component(): parentstate_(NULL), _parent(NULL), - Position(Point(0,0)), - Size(Point(0,0)), - Locked(false), - Visible(true), + drawn(false), textPosition(0, 0), textSize(0, 0), iconPosition(0, 0), - drawn(false), - menu(NULL) + menu(NULL), + Position(Point(0,0)), + Size(Point(0,0)), + Locked(false), + Visible(true) { } diff --git a/src/gui/interface/ContextMenu.cpp b/src/gui/interface/ContextMenu.cpp index dcf051f24..560b2305c 100644 --- a/src/gui/interface/ContextMenu.cpp +++ b/src/gui/interface/ContextMenu.cpp @@ -16,8 +16,8 @@ public: ContextMenu::ContextMenu(Component * source): Window(ui::Point(0, 0), ui::Point(0, 0)), - Appearance(source->Appearance), - source(source) + source(source), + Appearance(source->Appearance) { } diff --git a/src/gui/interface/ContextMenu.h b/src/gui/interface/ContextMenu.h index c7d8b5fb6..bbb1ef59f 100644 --- a/src/gui/interface/ContextMenu.h +++ b/src/gui/interface/ContextMenu.h @@ -14,7 +14,7 @@ public: int ID; std::string Text; bool Enabled; - ContextMenuItem(std::string text, int id, bool enabled) : Text(text), ID(id), Enabled(enabled) {} + ContextMenuItem(std::string text, int id, bool enabled) : ID(id), Text(text), Enabled(enabled) {} }; class ContextMenu: public ui::Window, public ButtonAction { diff --git a/src/gui/interface/DropDown.cpp b/src/gui/interface/DropDown.cpp index f1dda7c33..dc8841cd7 100644 --- a/src/gui/interface/DropDown.cpp +++ b/src/gui/interface/DropDown.cpp @@ -8,8 +8,8 @@ namespace ui { class ItemSelectedAction; class DropDownWindow: public ui::Window { friend class ItemSelectedAction; - Appearance appearance; DropDown * dropDown; + Appearance appearance; std::vector