diff --git a/.gitignore b/.gitignore index 04ca74fd9..ff267553a 100644 --- a/.gitignore +++ b/.gitignore @@ -38,6 +38,7 @@ Makefile.me *.ipch *.log *.lastbuildstate +*.unsuccessfulbuild *.pdb *.sublime-* *.project diff --git a/src/cat/LuaCheckbox.cpp b/src/cat/LuaCheckbox.cpp index 1ddc0c2e5..844573eac 100644 --- a/src/cat/LuaCheckbox.cpp +++ b/src/cat/LuaCheckbox.cpp @@ -33,7 +33,7 @@ LuaCheckbox::LuaCheckbox(lua_State * l) : int sizeY = luaL_optinteger(l, 4, 10); std::string text = luaL_optstring(l, 5, ""); - checkbox = new ui::Checkbox(ui::Point(posX, posY), ui::Point(sizeX, sizeY), text); + checkbox = new ui::Checkbox(ui::Point(posX, posY), ui::Point(sizeX, sizeY), text, ""); component = checkbox; class ClickAction : public ui::CheckboxAction { diff --git a/src/game/GameView.cpp b/src/game/GameView.cpp index 927b739b1..d162615ed 100644 --- a/src/game/GameView.cpp +++ b/src/game/GameView.cpp @@ -1491,7 +1491,7 @@ void GameView::OnTick(float dt) { toolTipPresence -= int(dt)>0?int(dt):1; if(toolTipPresence<0) - toolTipPresence = 0; + toolTipPresence = 0; } c->Update(); if(lastLogEntry > -0.1f) diff --git a/src/interface/Checkbox.cpp b/src/interface/Checkbox.cpp index c0dd47bad..d7be32480 100644 --- a/src/interface/Checkbox.cpp +++ b/src/interface/Checkbox.cpp @@ -9,9 +9,10 @@ using namespace ui; -Checkbox::Checkbox(ui::Point position, ui::Point size, std::string text): +Checkbox::Checkbox(ui::Point position, ui::Point size, std::string text, std::string toolTip): Component(position, size), text(text), + toolTip(toolTip), isMouseOver(false), checked(false), actionCallback(NULL) @@ -30,6 +31,13 @@ std::string Checkbox::GetText() return text; } +void Checkbox::SetIcon(Icon icon) +{ + Appearance.icon = icon; + iconPosition.X = 19; + iconPosition.Y = 3; +} + void Checkbox::OnMouseClick(int x, int y, unsigned int button) { if(checked) @@ -53,6 +61,10 @@ void Checkbox::OnMouseUp(int x, int y, unsigned int button) void Checkbox::OnMouseEnter(int x, int y) { isMouseOver = true; + if(toolTip.length()>0 && GetParentWindow()) + { + GetParentWindow()->ToolTip(this, ui::Point(x, y), toolTip); + } } void Checkbox::OnMouseLeave(int x, int y) @@ -71,12 +83,18 @@ void Checkbox::Draw(const Point& screenPos) { g->drawrect(screenPos.X+2, screenPos.Y+2, 12, 12, 255, 255, 255, 255); g->fillrect(screenPos.X+5, screenPos.Y+5, 6, 6, 255, 255, 255, 170); - g->drawtext(screenPos.X+18, screenPos.Y+4, text, 255, 255, 255, 255); + if (!Appearance.icon) + g->drawtext(screenPos.X+18, screenPos.Y+4, text, 255, 255, 255, 255); + else + g->draw_icon(screenPos.X+15, screenPos.Y+iconPosition.Y, Appearance.icon); } else { g->drawrect(screenPos.X+2, screenPos.Y+2, 12, 12, 255, 255, 255, 200); - g->drawtext(screenPos.X+18, screenPos.Y+4, text, 255, 255, 255, 200); + if (!Appearance.icon) + g->drawtext(screenPos.X+18, screenPos.Y+4, text, 255, 255, 255, 200); + else + g->draw_icon(screenPos.X+15, screenPos.Y+iconPosition.Y, Appearance.icon); } } diff --git a/src/interface/Checkbox.h b/src/interface/Checkbox.h index f9d305c38..132383148 100644 --- a/src/interface/Checkbox.h +++ b/src/interface/Checkbox.h @@ -21,13 +21,15 @@ public: }; class Checkbox: public ui::Component { std::string text; + std::string toolTip; bool checked; bool isMouseOver; CheckboxAction * actionCallback; public: - Checkbox(ui::Point position, ui::Point size, std::string text); + Checkbox(ui::Point position, ui::Point size, std::string text, std::string toolTip); void SetText(std::string text); std::string GetText(); + void SetIcon(Icon icon); void Draw(const Point& screenPos); virtual void OnMouseEnter(int x, int y); virtual void OnMouseLeave(int x, int y); diff --git a/src/options/OptionsView.cpp b/src/options/OptionsView.cpp index b0ed2cc75..9811154b5 100644 --- a/src/options/OptionsView.cpp +++ b/src/options/OptionsView.cpp @@ -27,7 +27,7 @@ OptionsView::OptionsView(): virtual void ActionCallback(ui::Checkbox * sender){ v->c->SetHeatSimulation(sender->GetChecked()); } }; - heatSimulation = new ui::Checkbox(ui::Point(8, 23), ui::Point(Size.X-6, 16), "Heat simulation \bgIntroduced in version 34"); + heatSimulation = new ui::Checkbox(ui::Point(8, 23), ui::Point(Size.X-6, 16), "Heat simulation \bgIntroduced in version 34", ""); heatSimulation->SetActionCallback(new HeatSimulationAction(this)); AddComponent(heatSimulation); tempLabel = new ui::Label(ui::Point(24, heatSimulation->Position.Y+14), ui::Point(Size.X-28, 16), "\bgCan cause odd behaviour with very old saves"); @@ -42,7 +42,7 @@ OptionsView::OptionsView(): virtual void ActionCallback(ui::Checkbox * sender){ v->c->SetAmbientHeatSimulation(sender->GetChecked()); } }; - ambientHeatSimulation = new ui::Checkbox(ui::Point(8, 53), ui::Point(Size.X-6, 16), "Ambient heat simulation \bgIntroduced in version 50"); + ambientHeatSimulation = new ui::Checkbox(ui::Point(8, 53), ui::Point(Size.X-6, 16), "Ambient heat simulation \bgIntroduced in version 50", ""); ambientHeatSimulation->SetActionCallback(new AmbientHeatSimulationAction(this)); AddComponent(ambientHeatSimulation); tempLabel = new ui::Label(ui::Point(24, ambientHeatSimulation->Position.Y+14), ui::Point(Size.X-28, 16), "\bgCan cause odd behaviour with old saves"); @@ -57,7 +57,7 @@ OptionsView::OptionsView(): virtual void ActionCallback(ui::Checkbox * sender){ v->c->SetNewtonianGravity(sender->GetChecked()); } }; - newtonianGravity = new ui::Checkbox(ui::Point(8, 83), ui::Point(Size.X-6, 16), "Newtonian gravity \bgIntroduced in version 48"); + newtonianGravity = new ui::Checkbox(ui::Point(8, 83), ui::Point(Size.X-6, 16), "Newtonian gravity \bgIntroduced in version 48", ""); newtonianGravity->SetActionCallback(new NewtonianGravityAction(this)); AddComponent(newtonianGravity); tempLabel = new ui::Label(ui::Point(24, newtonianGravity->Position.Y+14), ui::Point(Size.X-28, 16), "\bgMay cause poor performance on older computers"); @@ -72,7 +72,7 @@ OptionsView::OptionsView(): virtual void ActionCallback(ui::Checkbox * sender){ v->c->SetWaterEqualisation(sender->GetChecked()); } }; - waterEqualisation = new ui::Checkbox(ui::Point(8, 113), ui::Point(Size.X-6, 16), "Water equalisation \bgIntroduced in version 61"); + waterEqualisation = new ui::Checkbox(ui::Point(8, 113), ui::Point(Size.X-6, 16), "Water equalisation \bgIntroduced in version 61", ""); waterEqualisation->SetActionCallback(new WaterEqualisationAction(this)); AddComponent(waterEqualisation); tempLabel = new ui::Label(ui::Point(24, waterEqualisation->Position.Y+14), ui::Point(Size.X-28, 16), "\bgMay cause poor performance with a lot of water"); @@ -144,7 +144,7 @@ OptionsView::OptionsView(): virtual void ActionCallback(ui::Checkbox * sender){ v->c->SetScale(sender->GetChecked()); } }; - scale = new ui::Checkbox(ui::Point(8, 210), ui::Point(Size.X-6, 16), "Large screen"); + scale = new ui::Checkbox(ui::Point(8, 210), ui::Point(Size.X-6, 16), "Large screen", ""); scale->SetActionCallback(new ScaleAction(this)); AddComponent(scale); @@ -156,7 +156,7 @@ OptionsView::OptionsView(): virtual void ActionCallback(ui::Checkbox * sender){ v->c->SetFullscreen(sender->GetChecked()); } }; - fullscreen = new ui::Checkbox(ui::Point(8, 230), ui::Point(Size.X-6, 16), "Fullscreen"); + fullscreen = new ui::Checkbox(ui::Point(8, 230), ui::Point(Size.X-6, 16), "Fullscreen", ""); fullscreen->SetActionCallback(new FullscreenAction(this)); AddComponent(fullscreen); diff --git a/src/render/RenderView.cpp b/src/render/RenderView.cpp index ed8e51f6c..d29b4267a 100644 --- a/src/render/RenderView.cpp +++ b/src/render/RenderView.cpp @@ -69,96 +69,98 @@ public: RenderView::RenderView(): ui::Window(ui::Point(0, 0), ui::Point(XRES, YRES+MENUSIZE)), + toolTip(""), + toolTipPresence(0), ren(NULL) { ui::Checkbox * tCheckbox; - tCheckbox = new ui::Checkbox(ui::Point(1, YRES+4), ui::Point(55, 16), "Effects"); + tCheckbox = new ui::Checkbox(ui::Point(1, YRES+4), ui::Point(55, 16), "Effects", ""); renderModes.push_back(tCheckbox); tCheckbox->SetActionCallback(new RenderModeAction(this, RENDER_EFFE)); AddComponent(tCheckbox); - tCheckbox = new ui::Checkbox(ui::Point(1, YRES+4+18), ui::Point(55, 16), "Fire"); + tCheckbox = new ui::Checkbox(ui::Point(1, YRES+4+18), ui::Point(55, 16), "Fire", ""); renderModes.push_back(tCheckbox); tCheckbox->SetActionCallback(new RenderModeAction(this, RENDER_FIRE)); AddComponent(tCheckbox); - tCheckbox = new ui::Checkbox(ui::Point(61, YRES+4), ui::Point(55, 16), "Glow"); + tCheckbox = new ui::Checkbox(ui::Point(61, YRES+4), ui::Point(55, 16), "Glow", ""); renderModes.push_back(tCheckbox); tCheckbox->SetActionCallback(new RenderModeAction(this, RENDER_GLOW)); AddComponent(tCheckbox); - tCheckbox = new ui::Checkbox(ui::Point(61, YRES+4+18), ui::Point(55, 16), "Blur"); + tCheckbox = new ui::Checkbox(ui::Point(61, YRES+4+18), ui::Point(55, 16), "Blur", ""); renderModes.push_back(tCheckbox); tCheckbox->SetActionCallback(new RenderModeAction(this, RENDER_BLUR)); AddComponent(tCheckbox); - tCheckbox = new ui::Checkbox(ui::Point(121, YRES+4), ui::Point(55, 16), "Blob"); + tCheckbox = new ui::Checkbox(ui::Point(121, YRES+4), ui::Point(55, 16), "Blob", ""); renderModes.push_back(tCheckbox); tCheckbox->SetActionCallback(new RenderModeAction(this, RENDER_BLOB)); AddComponent(tCheckbox); - tCheckbox = new ui::Checkbox(ui::Point(121, YRES+4+18), ui::Point(55, 16), "Point"); + tCheckbox = new ui::Checkbox(ui::Point(121, YRES+4+18), ui::Point(55, 16), "Point", ""); renderModes.push_back(tCheckbox); tCheckbox->SetActionCallback(new RenderModeAction(this, RENDER_BASC)); AddComponent(tCheckbox); - tCheckbox = new ui::Checkbox(ui::Point(186, YRES+4), ui::Point(70, 16), "Alt. Air"); + tCheckbox = new ui::Checkbox(ui::Point(186, YRES+4), ui::Point(70, 16), "Alt. Air", ""); displayModes.push_back(tCheckbox); tCheckbox->SetActionCallback(new DisplayModeAction(this, DISPLAY_AIRC)); AddComponent(tCheckbox); - tCheckbox = new ui::Checkbox(ui::Point(186, YRES+4+18), ui::Point(70, 16), "Pressure"); + tCheckbox = new ui::Checkbox(ui::Point(186, YRES+4+18), ui::Point(70, 16), "Pressure", ""); displayModes.push_back(tCheckbox); tCheckbox->SetActionCallback(new DisplayModeAction(this, DISPLAY_AIRP)); AddComponent(tCheckbox); - tCheckbox = new ui::Checkbox(ui::Point(261, YRES+4), ui::Point(70, 16), "Velocity"); + tCheckbox = new ui::Checkbox(ui::Point(261, YRES+4), ui::Point(70, 16), "Velocity", ""); displayModes.push_back(tCheckbox); tCheckbox->SetActionCallback(new DisplayModeAction(this, DISPLAY_AIRV)); AddComponent(tCheckbox); - tCheckbox = new ui::Checkbox(ui::Point(261, YRES+4+18), ui::Point(70, 16), "Air-heat"); + tCheckbox = new ui::Checkbox(ui::Point(261, YRES+4+18), ui::Point(70, 16), "Air-heat", ""); displayModes.push_back(tCheckbox); tCheckbox->SetActionCallback(new DisplayModeAction(this, DISPLAY_AIRH)); AddComponent(tCheckbox); - /*tCheckbox = new ui::Checkbox(ui::Point(336, YRES+4), ui::Point(70, 16), "Air"); + /*tCheckbox = new ui::Checkbox(ui::Point(336, YRES+4), ui::Point(70, 16), "Air", ""); displayModes.push_back(tCheckbox); tCheckbox->SetActionCallback(new DisplayModeAction(this, DISPLAY_AIR)); AddComponent(tCheckbox);*/ - tCheckbox = new ui::Checkbox(ui::Point(336, YRES+4+18), ui::Point(70, 16), "Warp"); + tCheckbox = new ui::Checkbox(ui::Point(336, YRES+4+18), ui::Point(70, 16), "Warp", ""); displayModes.push_back(tCheckbox); tCheckbox->SetActionCallback(new DisplayModeAction(this, DISPLAY_WARP)); AddComponent(tCheckbox); - tCheckbox = new ui::Checkbox(ui::Point(411, YRES+4), ui::Point(70, 16), "Persistent"); + tCheckbox = new ui::Checkbox(ui::Point(411, YRES+4), ui::Point(70, 16), "Persistent", ""); displayModes.push_back(tCheckbox); tCheckbox->SetActionCallback(new DisplayModeAction(this, DISPLAY_PERS)); AddComponent(tCheckbox); - tCheckbox = new ui::Checkbox(ui::Point(336, YRES+4), ui::Point(70, 16), "Effect"); + tCheckbox = new ui::Checkbox(ui::Point(336, YRES+4), ui::Point(70, 16), "Effect", ""); displayModes.push_back(tCheckbox); tCheckbox->SetActionCallback(new DisplayModeAction(this, DISPLAY_EFFE)); AddComponent(tCheckbox); - tCheckbox = new ui::Checkbox(ui::Point(486, YRES+4), ui::Point(50, 16), "Heat"); + tCheckbox = new ui::Checkbox(ui::Point(486, YRES+4), ui::Point(50, 16), "Heat", ""); colourModes.push_back(tCheckbox); tCheckbox->SetActionCallback(new ColourModeAction(this, COLOUR_HEAT)); AddComponent(tCheckbox); - tCheckbox = new ui::Checkbox(ui::Point(486, YRES+4+18), ui::Point(50, 16), "Life"); + tCheckbox = new ui::Checkbox(ui::Point(486, YRES+4+18), ui::Point(50, 16), "Life", ""); colourModes.push_back(tCheckbox); tCheckbox->SetActionCallback(new ColourModeAction(this, COLOUR_LIFE)); AddComponent(tCheckbox); - tCheckbox = new ui::Checkbox(ui::Point(536, YRES+4+18), ui::Point(50, 16), "H-Gradient"); + tCheckbox = new ui::Checkbox(ui::Point(536, YRES+4+18), ui::Point(50, 16), "H-Gradient", ""); colourModes.push_back(tCheckbox); tCheckbox->SetActionCallback(new ColourModeAction(this, COLOUR_GRAD)); AddComponent(tCheckbox); - tCheckbox = new ui::Checkbox(ui::Point(536, YRES+4), ui::Point(50, 16), "Basic"); + tCheckbox = new ui::Checkbox(ui::Point(536, YRES+4), ui::Point(50, 16), "Basic", ""); colourModes.push_back(tCheckbox); tCheckbox->SetActionCallback(new ColourModeAction(this, COLOUR_BASC)); AddComponent(tCheckbox); @@ -236,18 +238,38 @@ void RenderView::NotifyColourChanged(RenderModel * sender) void RenderView::OnDraw() { Graphics * g = ui::Engine::Ref().g; - g->clearrect(0, 0, XRES, YRES+MENUSIZE); + g->clearrect(-1, -1, XRES+BARSIZE+1, YRES+MENUSIZE+1); if(ren) { ren->clearScreen(1.0f); ren->RenderBegin(); ren->RenderEnd(); } - g->draw_line(0, YRES, XRES-1, YRES, 255, 255, 255, XRES+BARSIZE); - g->draw_line(180, YRES, 180, YRES+MENUSIZE, 200, 200, 200, XRES+BARSIZE); - g->draw_line(330, YRES, 330, YRES+MENUSIZE, 200, 200, 200, XRES+BARSIZE); - g->draw_line(480, YRES, 480, YRES+MENUSIZE, 200, 200, 200, XRES+BARSIZE); - g->draw_line(XRES-1, 0, XRES-1, YRES+MENUSIZE, 255, 255, 255, XRES+BARSIZE); + g->draw_line(0, YRES, XRES-1, YRES, 200, 200, 200, 255); + g->draw_line(180, YRES, 180, YRES+MENUSIZE, 200, 200, 200, 255); + g->draw_line(330, YRES, 330, YRES+MENUSIZE, 200, 200, 200, 255); + g->draw_line(480, YRES, 480, YRES+MENUSIZE, 200, 200, 200, 255); + g->draw_line(XRES, 0, XRES, YRES+MENUSIZE, 255, 255, 255, 255); + if(toolTipPresence && toolTip.length()) + { + g->drawtext(6, Size.Y-MENUSIZE-10, (char*)toolTip.c_str(), 255, 255, 255, toolTipPresence>51?255:toolTipPresence*5); + } +} + +void RenderView::OnTick(float dt) +{ + if(toolTipPresence>0) + { + toolTipPresence -= int(dt)>0?int(dt):1; + if(toolTipPresence<0) + toolTipPresence = 0; + } +} + +void RenderView::ToolTip(ui::Component * sender, ui::Point mousePosition, std::string toolTip) +{ + this->toolTip = toolTip; + toolTipPresence = 160; } RenderView::~RenderView() { diff --git a/src/render/RenderView.h b/src/render/RenderView.h index c08491639..695a342e8 100644 --- a/src/render/RenderView.h +++ b/src/render/RenderView.h @@ -24,6 +24,8 @@ class RenderView: public ui::Window { std::vector renderModes; std::vector displayModes; std::vector colourModes; + std::string toolTip; + int toolTipPresence; public: class RenderModeAction; class DisplayModeAction; @@ -36,6 +38,8 @@ public: void AttachController(RenderController * c_) { c = c_; } void OnMouseDown(int x, int y, unsigned button); virtual void OnDraw(); + virtual void OnTick(float dt); + virtual void ToolTip(ui::Component * sender, ui::Point mousePosition, std::string toolTip); virtual ~RenderView(); }; diff --git a/src/save/ServerSaveActivity.cpp b/src/save/ServerSaveActivity.cpp index b8661a8cb..a704e85a4 100644 --- a/src/save/ServerSaveActivity.cpp +++ b/src/save/ServerSaveActivity.cpp @@ -97,7 +97,7 @@ ServerSaveActivity::ServerSaveActivity(SaveInfo save, ServerSaveActivity::SaveUp descriptionField->Appearance.HorizontalAlign = ui::Appearance::AlignLeft; AddComponent(descriptionField); - publishedCheckbox = new ui::Checkbox(ui::Point(8, 45), ui::Point((Size.X/2)-16, 16), "Publish"); + publishedCheckbox = new ui::Checkbox(ui::Point(8, 45), ui::Point((Size.X/2)-16, 16), "Publish", ""); if(Client::Ref().GetAuthUser().Username != save.GetUserName()) { //Save is not owned by the user, disable by default