diff options
| author | build.powdertoy.co.uk <admin@powdertoy.co.uk> | 2012-07-19 17:08:34 (GMT) |
|---|---|---|
| committer | build.powdertoy.co.uk <admin@powdertoy.co.uk> | 2012-07-19 17:08:34 (GMT) |
| commit | d328b84b1330b0e8f3a7f87ce48b9b20ea4b6d01 (patch) | |
| tree | db311c7849270ddd2510cbd65a192b059f8a3c77 /src/game | |
| parent | d71af3706a7a14e8ae65523e1a062417818b8fe2 (diff) | |
| parent | 4d961117bde4398ae4d72f2db96eef381371e2df (diff) | |
| download | powder-d328b84b1330b0e8f3a7f87ce48b9b20ea4b6d01.zip powder-d328b84b1330b0e8f3a7f87ce48b9b20ea4b6d01.tar.gz | |
Merge branch 'master' of github.com:FacialTurd/PowderToypp
Diffstat (limited to 'src/game')
| -rw-r--r-- | src/game/DecorationTool.h | 4 | ||||
| -rw-r--r-- | src/game/GameController.cpp | 22 | ||||
| -rw-r--r-- | src/game/GameController.h | 2 | ||||
| -rw-r--r-- | src/game/GameModel.cpp | 67 | ||||
| -rw-r--r-- | src/game/GameModel.h | 10 | ||||
| -rw-r--r-- | src/game/GameView.cpp | 122 | ||||
| -rw-r--r-- | src/game/GameView.h | 14 | ||||
| -rw-r--r-- | src/game/RenderPreset.h | 19 | ||||
| -rw-r--r-- | src/game/Tool.cpp | 29 | ||||
| -rw-r--r-- | src/game/Tool.h | 29 | ||||
| -rw-r--r-- | src/game/ToolButton.cpp | 4 | ||||
| -rw-r--r-- | src/game/ToolButton.h | 2 |
12 files changed, 278 insertions, 46 deletions
diff --git a/src/game/DecorationTool.h b/src/game/DecorationTool.h index c45eca3..be79e6b 100644 --- a/src/game/DecorationTool.h +++ b/src/game/DecorationTool.h @@ -16,8 +16,8 @@ public: unsigned char Blue; unsigned char Alpha; - DecorationTool(ToolType decoMode_, string name, int r, int g, int b): - Tool(0, name, r, g, b), + DecorationTool(ToolType decoMode_, string name, string description, int r, int g, int b): + Tool(0, name, description, r, g, b), decoMode(decoMode_), Red(0), Green(0), diff --git a/src/game/GameController.cpp b/src/game/GameController.cpp index 8ece34b..72c38c0 100644 --- a/src/game/GameController.cpp +++ b/src/game/GameController.cpp @@ -402,6 +402,15 @@ void GameController::Exit() HasDone = true; } +void GameController::LoadRenderPreset(RenderPreset preset) +{ + Renderer * renderer = gameModel->GetRenderer(); + gameModel->SetInfoTip(preset.Name); + renderer->SetRenderMode(preset.RenderModes); + renderer->SetDisplayMode(preset.DisplayModes); + renderer->SetColourMode(preset.ColourMode); +} + void GameController::Update() { ui::Point pos = gameView->GetMousePosition(); @@ -681,7 +690,18 @@ void GameController::NotifyUpdateAvailable(Client * sender) } }; - gameModel->AddNotification(new UpdateNotification(this, "A new version is available - click here to download")); + switch(sender->GetUpdateInfo().Type) + { + case UpdateInfo::Snapshot: + gameModel->AddNotification(new UpdateNotification(this, std::string("A new snapshot is available - click here to update"))); + break; + case UpdateInfo::Stable: + gameModel->AddNotification(new UpdateNotification(this, std::string("A new version is available - click here to update"))); + break; + case UpdateInfo::Beta: + gameModel->AddNotification(new UpdateNotification(this, std::string("A new beta is available - click here to update"))); + break; + } } void GameController::RemoveNotification(Notification * notification) diff --git a/src/game/GameController.h b/src/game/GameController.h index 4e2b43a..2388c5d 100644 --- a/src/game/GameController.h +++ b/src/game/GameController.h @@ -17,6 +17,7 @@ #include "cat/LuaScriptInterface.h" #include "options/OptionsController.h" #include "client/ClientListener.h" +#include "RenderPreset.h" #include "Menu.h" using namespace std; @@ -63,6 +64,7 @@ public: void Tick(); void Exit(); + void LoadRenderPreset(RenderPreset preset); void SetZoomEnabled(bool zoomEnable); void SetZoomPosition(ui::Point position); void AdjustBrushSize(int direction, bool logarithmic = false); diff --git a/src/game/GameModel.cpp b/src/game/GameModel.cpp index 668b755..e4ee15b 100644 --- a/src/game/GameModel.cpp +++ b/src/game/GameModel.cpp @@ -61,7 +61,15 @@ GameModel::GameModel(): { if(sim->elements[i].MenuSection < 12 && sim->elements[i].Enabled && sim->elements[i].MenuVisible) { - Tool * tempTool = new ElementTool(i, sim->elements[i].Name, PIXR(sim->elements[i].Colour), PIXG(sim->elements[i].Colour), PIXB(sim->elements[i].Colour)); + Tool * tempTool; + if(i == PT_LIGH) + { + tempTool = new Element_LIGH_Tool(i, sim->elements[i].Name, sim->elements[i].Description, PIXR(sim->elements[i].Colour), PIXG(sim->elements[i].Colour), PIXB(sim->elements[i].Colour)); + } + else + { + tempTool = new ElementTool(i, sim->elements[i].Name, sim->elements[i].Description, PIXR(sim->elements[i].Colour), PIXG(sim->elements[i].Colour), PIXB(sim->elements[i].Colour)); + } menuList[sim->elements[i].MenuSection]->AddTool(tempTool); } } @@ -69,14 +77,14 @@ GameModel::GameModel(): //Build menu for GOL types for(int i = 0; i < NGOL; i++) { - Tool * tempTool = new GolTool(i, sim->gmenu[i].name, PIXR(sim->gmenu[i].colour), PIXG(sim->gmenu[i].colour), PIXB(sim->gmenu[i].colour)); + 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)); menuList[SC_LIFE]->AddTool(tempTool); } //Build other menus from wall data for(int i = 0; i < UI_WALLCOUNT; i++) { - Tool * tempTool = new WallTool(i, "", PIXR(sim->wtypes[i].colour), PIXG(sim->wtypes[i].colour), PIXB(sim->wtypes[i].colour)); + Tool * tempTool = new WallTool(i, "", std::string(sim->wtypes[i].descs), PIXR(sim->wtypes[i].colour), PIXG(sim->wtypes[i].colour), PIXB(sim->wtypes[i].colour)); menuList[SC_WALL]->AddTool(tempTool); //sim->wtypes[i] } @@ -88,17 +96,18 @@ GameModel::GameModel(): //Build menu for simtools for(int i = 0; i < sim->tools.size(); i++) { - Tool * tempTool = new Tool(i, sim->tools[i]->Name, PIXR(sim->tools[i]->Colour), PIXG(sim->tools[i]->Colour), PIXB(sim->tools[i]->Colour)); + 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)); menuList[SC_TOOL]->AddTool(tempTool); } //Add decoration tools to menu - menuList[SC_DECO]->AddTool(new DecorationTool(DecorationTool::BlendAdd, "ADD", 0, 0, 0)); - menuList[SC_DECO]->AddTool(new DecorationTool(DecorationTool::BlendRemove, "SUB", 0, 0, 0)); - menuList[SC_DECO]->AddTool(new DecorationTool(DecorationTool::BlendMultiply, "MUL", 0, 0, 0)); - menuList[SC_DECO]->AddTool(new DecorationTool(DecorationTool::BlendDivide, "DIV", 0, 0, 0)); - menuList[SC_DECO]->AddTool(new DecorationTool(DecorationTool::BlendSmudge, "SMDG", 0, 0, 0)); - menuList[SC_DECO]->AddTool(new DecorationTool(DecorationTool::BlendSet, "SET", 0, 0, 0)); + menuList[SC_DECO]->AddTool(new DecorationTool(DecorationTool::BlendAdd, "ADD", "Colour blending: Add", 0, 0, 0)); + menuList[SC_DECO]->AddTool(new DecorationTool(DecorationTool::BlendRemove, "SUB", "Colour blending: Subtract", 0, 0, 0)); + menuList[SC_DECO]->AddTool(new DecorationTool(DecorationTool::BlendMultiply, "MUL", "Colour blending: Multiply", 0, 0, 0)); + menuList[SC_DECO]->AddTool(new DecorationTool(DecorationTool::BlendDivide, "DIV", "Colour blending: Divide" , 0, 0, 0)); + menuList[SC_DECO]->AddTool(new DecorationTool(DecorationTool::BlendSmudge, "SMDG", "Smudge colour", 0, 0, 0)); + menuList[SC_DECO]->AddTool(new DecorationTool(DecorationTool::BlendSet, "SET", "Set colour (No blending)", 0, 0, 0)); //Set default brush palette brushList.push_back(new EllipseBrush(ui::Point(4, 4))); @@ -517,6 +526,28 @@ void GameModel::RemoveNotification(Notification * notification) notifyNotificationsChanged(); } +void GameModel::SetToolTip(std::string text) +{ + toolTip = text; + notifyToolTipChanged(); +} + +void GameModel::SetInfoTip(std::string text) +{ + infoTip = text; + notifyInfoTipChanged(); +} + +std::string GameModel::GetToolTip() +{ + return toolTip; +} + +std::string GameModel::GetInfoTip() +{ + return infoTip; +} + void GameModel::notifyNotificationsChanged() { for(std::vector<GameView*>::iterator iter = observers.begin(); iter != observers.end(); ++iter) @@ -644,3 +675,19 @@ void GameModel::notifyLogChanged(string entry) observers[i]->NotifyLogChanged(this, entry); } } + +void GameModel::notifyInfoTipChanged() +{ + for(int i = 0; i < observers.size(); i++) + { + observers[i]->NotifyInfoTipChanged(this); + } +} + +void GameModel::notifyToolTipChanged() +{ + for(int i = 0; i < observers.size(); i++) + { + observers[i]->NotifyToolTipChanged(this); + } +}
\ No newline at end of file diff --git a/src/game/GameModel.h b/src/game/GameModel.h index 5f656c1..28b86e6 100644 --- a/src/game/GameModel.h +++ b/src/game/GameModel.h @@ -53,6 +53,9 @@ private: User currentUser; bool colourSelector; ui::Colour colour; + + std::string infoTip; + std::string toolTip; //bool zoomEnabled; void notifyRendererChanged(); void notifySimulationChanged(); @@ -71,6 +74,8 @@ private: void notifyColourSelectorVisibilityChanged(); void notifyNotificationsChanged(); void notifyLogChanged(string entry); + void notifyInfoTipChanged(); + void notifyToolTipChanged(); public: GameModel(); ~GameModel(); @@ -81,6 +86,11 @@ public: void SetColourSelectorColour(ui::Colour colour); ui::Colour GetColourSelectorColour(); + void SetToolTip(std::string text); + void SetInfoTip(std::string text); + std::string GetToolTip(); + std::string GetInfoTip(); + void SetVote(int direction); SaveInfo * GetSave(); Brush * GetBrush(); diff --git a/src/game/GameView.cpp b/src/game/GameView.cpp index dd03987..4f9c41a 100644 --- a/src/game/GameView.cpp +++ b/src/game/GameView.cpp @@ -33,7 +33,11 @@ GameView::GameView(): placeSaveThumb(NULL), mousePosition(0, 0), lastOffset(0), - drawSnap(false) + drawSnap(false), + toolTip(""), + infoTip(""), + infoTipPresence(0), + toolTipPosition(-1, -1) { int currentX = 1; @@ -255,6 +259,59 @@ GameView::GameView(): tempButton->Appearance.Margin = ui::Border(0, 2, 3, 2); tempButton->SetActionCallback(new ElementSearchAction(this)); AddComponent(tempButton); + + //Render mode presets. Possibly load from config in future? + renderModePresets = new RenderPreset[10]; + + renderModePresets[0].Name = "Alternative Velocity Display"; + renderModePresets[0].RenderModes.push_back(RENDER_EFFE); + renderModePresets[0].RenderModes.push_back(RENDER_BASC); + renderModePresets[0].DisplayModes.push_back(DISPLAY_AIRC); + + renderModePresets[1].Name = "Velocity Display"; + renderModePresets[1].RenderModes.push_back(RENDER_EFFE); + renderModePresets[1].RenderModes.push_back(RENDER_BASC); + renderModePresets[1].DisplayModes.push_back(DISPLAY_AIRV); + + renderModePresets[2].Name = "Pressure Display"; + renderModePresets[2].RenderModes.push_back(RENDER_EFFE); + renderModePresets[2].RenderModes.push_back(RENDER_BASC); + renderModePresets[2].DisplayModes.push_back(DISPLAY_AIRP); + + renderModePresets[3].Name = "Persistent Display"; + renderModePresets[3].RenderModes.push_back(RENDER_EFFE); + renderModePresets[3].RenderModes.push_back(RENDER_BASC); + renderModePresets[3].DisplayModes.push_back(DISPLAY_PERS); + + renderModePresets[4].Name = "Fire Display"; + renderModePresets[4].RenderModes.push_back(RENDER_FIRE); + renderModePresets[4].RenderModes.push_back(RENDER_EFFE); + renderModePresets[4].RenderModes.push_back(RENDER_BASC); + + renderModePresets[5].Name = "Blob Display"; + renderModePresets[5].RenderModes.push_back(RENDER_FIRE); + renderModePresets[5].RenderModes.push_back(RENDER_EFFE); + renderModePresets[5].RenderModes.push_back(RENDER_BLOB); + + renderModePresets[6].Name = "Heat Display"; + renderModePresets[6].RenderModes.push_back(RENDER_BASC); + renderModePresets[6].DisplayModes.push_back(DISPLAY_AIRH); + renderModePresets[6].ColourMode = COLOUR_HEAT; + + renderModePresets[7].Name = "Fancy Display"; + renderModePresets[7].RenderModes.push_back(RENDER_FIRE); + renderModePresets[7].RenderModes.push_back(RENDER_GLOW); + renderModePresets[7].RenderModes.push_back(RENDER_BLUR); + renderModePresets[7].RenderModes.push_back(RENDER_EFFE); + renderModePresets[7].RenderModes.push_back(RENDER_BASC); + renderModePresets[7].DisplayModes.push_back(DISPLAY_WARP); + + renderModePresets[8].Name = "Nothing Display"; + renderModePresets[8].RenderModes.push_back(RENDER_BASC); + + renderModePresets[9].Name = "Heat Gradient Display"; + renderModePresets[9].RenderModes.push_back(RENDER_BASC); + renderModePresets[9].ColourMode = COLOUR_GRAD; } class GameView::MenuAction: public ui::ButtonAction @@ -308,7 +365,7 @@ void GameView::NotifyMenuListChanged(GameModel * sender) 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); + ui::Button * tempButton = new ui::Button(ui::Point(XRES+BARSIZE-16, currentY), ui::Point(15, 15), tempString, item->GetDescription()); tempButton->Appearance.Margin = ui::Border(0, 2, 3, 2); tempButton->SetTogglable(true); tempButton->SetActionCallback(new MenuAction(this, item)); @@ -379,7 +436,7 @@ void GameView::NotifyToolListChanged(GameModel * sender) for(int i = 0; i < toolList.size(); i++) { //ToolButton * tempButton = new ToolButton(ui::Point(XRES+1, currentY), ui::Point(28, 15), toolList[i]->GetName()); - ToolButton * tempButton = new ToolButton(ui::Point(currentX, YRES+1), ui::Point(30, 18), toolList[i]->GetName()); + ToolButton * tempButton = new ToolButton(ui::Point(currentX, YRES+1), ui::Point(30, 18), toolList[i]->GetName(), toolList[i]->GetDescription()); //currentY -= 17; currentX -= 31; tempButton->SetActionCallback(new ToolAction(this, toolList[i])); @@ -467,6 +524,17 @@ void GameView::NotifyPausedChanged(GameModel * sender) pauseButton->SetToggleState(sender->GetPaused()); } +void GameView::NotifyToolTipChanged(GameModel * sender) +{ + toolTip = sender->GetToolTip(); +} + +void GameView::NotifyInfoTipChanged(GameModel * sender) +{ + infoTip = sender->GetInfoTip(); + infoTipPresence = 120; +} + void GameView::NotifySaveChanged(GameModel * sender) { if(sender->GetSave()) @@ -675,6 +743,12 @@ void GameView::OnMouseUp(int x, int y, unsigned button) } } +void GameView::ToolTip(ui::Component * sender, ui::Point mousePosition, std::string toolTip) +{ + this->toolTip = toolTip; + toolTipPosition = ui::Point(Size.X-27-Graphics::textwidth((char*)toolTip.c_str()), Size.Y-MENUSIZE-10); +} + void GameView::OnMouseWheel(int x, int y, int d) { if(!d) @@ -819,6 +893,11 @@ void GameView::OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool c->AdjustBrushSize(-1, true); break; } + + if(key >= '0' && key <= '9') + { + c->LoadRenderPreset(renderModePresets[key-'0']); + } } void GameView::OnKeyRelease(int key, Uint16 character, bool shift, bool ctrl, bool alt) @@ -864,6 +943,12 @@ void GameView::OnTick(float dt) { c->DrawFill(toolIndex, currentMouse); } + if(infoTipPresence>0) + { + infoTipPresence -= int(dt)>0?int(dt):1; + if(infoTipPresence<0) + infoTipPresence = 0; + } c->Update(); if(lastLogEntry > -0.1f) lastLogEntry -= 0.16*dt; @@ -975,16 +1060,18 @@ void GameView::NotifyNotificationsChanged(GameModel * sender) } }; - for(std::vector<ui::Component*>::iterator iter = notificationComponents.begin(); iter != notificationComponents.end(); ++iter) { - RemoveComponent(*iter); - delete *iter; + for(std::vector<ui::Component*>::const_iterator iter = notificationComponents.begin(), end = notificationComponents.end(); iter != end; ++iter) { + ui::Component * cNotification = *iter; + RemoveComponent(cNotification); + delete cNotification; } notificationComponents.clear(); + std::vector<Notification*> notifications = sender->GetNotifications(); int currentY = YRES-17; - for(std::vector<Notification*>::iterator iter = notifications.begin(); iter != notifications.end(); ++iter) + for(std::vector<Notification*>::iterator iter = notifications.begin(), end = notifications.end(); iter != end; ++iter) { int width = (Graphics::textwidth((*iter)->Message.c_str()))+8; ui::Button * tempButton = new ui::Button(ui::Point(XRES-width-22, currentY), ui::Point(width, 15), (*iter)->Message); @@ -1046,13 +1133,7 @@ void GameView::OnDraw() if(ren) { ren->clearScreen(1.0f); - ren->draw_air(); - ren->render_parts(); - ren->render_fire(); - ren->draw_grav(); - ren->DrawWalls(); - ren->DrawSigns(); - ren->FinaliseParts(); + ren->RenderBegin(); if(activeBrush && currentMouse.X > 0 && currentMouse.X < XRES && currentMouse.Y > 0 && currentMouse.Y < YRES) { ui::Point finalCurrentMouse = c->PointTranslate(currentMouse); @@ -1082,7 +1163,7 @@ void GameView::OnDraw() activeBrush->RenderPoint(g, finalCurrentMouse); } } - ren->RenderZoom(); + ren->RenderEnd(); if(selectMode!=SelectNone) { @@ -1167,6 +1248,17 @@ void GameView::OnDraw() sampleInfo << ", Ctype: " << c->ElementResolve(sample.ctype); g->drawtext(XRES+BARSIZE-(10+Graphics::textwidth((char*)sampleInfo.str().c_str())), 10, (const char*)sampleInfo.str().c_str(), 255, 255, 255, 255); + + if(infoTipPresence) + { + int infoTipAlpha = (infoTipPresence>50?50:infoTipPresence)*5; + g->drawtext((XRES-Graphics::textwidth((char*)infoTip.c_str()))/2, (YRES/2)-2, (char*)infoTip.c_str(), 255, 255, 255, infoTipAlpha); + } + + if(toolTipPosition.X!=-1 && toolTipPosition.Y!=-1 && toolTip.length()) + { + g->drawtext(toolTipPosition.X, toolTipPosition.Y, (char*)toolTip.c_str(), 255, 255, 255, 255); + } } ui::Point GameView::lineSnapCoords(ui::Point point1, ui::Point point2) diff --git a/src/game/GameView.h b/src/game/GameView.h index 4576b13..4a841c1 100644 --- a/src/game/GameView.h +++ b/src/game/GameView.h @@ -12,6 +12,7 @@ #include "interface/Button.h" #include "interface/Slider.h" #include "ToolButton.h" +#include "RenderPreset.h" #include "Brush.h" using namespace std; @@ -37,6 +38,12 @@ private: bool zoomCursorFixed; bool drawSnap; int toolIndex; + + int infoTipPresence; + std::string toolTip; + ui::Point toolTipPosition; + std::string infoTip; + queue<ui::Point*> pointQueue; GameController * c; Renderer * ren; @@ -76,6 +83,8 @@ private: ui::Point mousePosition; + RenderPreset * renderModePresets; + Thumbnail * placeSaveThumb; Particle sample; @@ -108,6 +117,11 @@ public: void NotifyPlaceSaveChanged(GameModel * sender); void NotifyNotificationsChanged(GameModel * sender); void NotifyLogChanged(GameModel * sender, string entry); + void NotifyToolTipChanged(GameModel * sender); + void NotifyInfoTipChanged(GameModel * sender); + + virtual void ToolTip(ui::Component * sender, ui::Point mousePosition, std::string toolTip); + virtual void OnMouseMove(int x, int y, int dx, int dy); virtual void OnMouseDown(int x, int y, unsigned button); virtual void OnMouseUp(int x, int y, unsigned button); diff --git a/src/game/RenderPreset.h b/src/game/RenderPreset.h new file mode 100644 index 0000000..9cc9f4c --- /dev/null +++ b/src/game/RenderPreset.h @@ -0,0 +1,19 @@ +#ifndef RENDER_PRESET_H +#define RENDER_PRESET_H +class RenderPreset +{ +public: + std::string Name; + std::vector<unsigned int> RenderModes; + std::vector<unsigned int> DisplayModes; + unsigned int ColourMode; + + RenderPreset(): Name(""), ColourMode(0) {} + RenderPreset(std::string name, std::vector<unsigned int> renderModes, std::vector<unsigned int> displayModes, unsigned int colourMode): + Name(name), + RenderModes(renderModes), + DisplayModes(displayModes), + ColourMode(colourMode) + {} +}; +#endif
\ No newline at end of file diff --git a/src/game/Tool.cpp b/src/game/Tool.cpp index 2467d3f..efe4831 100644 --- a/src/game/Tool.cpp +++ b/src/game/Tool.cpp @@ -12,15 +12,17 @@ using namespace std; -Tool::Tool(int id, string name, int r, int g, int b): +Tool::Tool(int id, string name, string description, int r, int g, int b): toolID(id), toolName(name), + toolDescription(description), colRed(r), colGreen(g), colBlue(b) { } string Tool::GetName() { return toolName; } +string Tool::GetDescription() { return toolDescription; } Tool::~Tool() {} void Tool::Click(Simulation * sim, Brush * brush, ui::Point position) { } void Tool::Draw(Simulation * sim, Brush * brush, ui::Point position) { @@ -34,8 +36,8 @@ void Tool::DrawRect(Simulation * sim, Brush * brush, ui::Point position1, ui::Po } void Tool::DrawFill(Simulation * sim, Brush * brush, ui::Point position) {}; -ElementTool::ElementTool(int id, string name, int r, int g, int b): - Tool(id, name, r, g, b) +ElementTool::ElementTool(int id, string name, string description, int r, int g, int b): + Tool(id, name, description, r, g, b) { } ElementTool::~ElementTool() {} @@ -53,8 +55,8 @@ void ElementTool::DrawFill(Simulation * sim, Brush * brush, ui::Point position) } -WallTool::WallTool(int id, string name, int r, int g, int b): -Tool(id, name, r, g, b) +WallTool::WallTool(int id, string name, string description, int r, int g, int b): +Tool(id, name, description, r, g, b) { } WallTool::~WallTool() {} @@ -72,8 +74,8 @@ void WallTool::DrawFill(Simulation * sim, Brush * brush, ui::Point position) { } -GolTool::GolTool(int id, string name, int r, int g, int b): - Tool(id, name, r, g, b) +GolTool::GolTool(int id, string name, string description, int r, int g, int b): + Tool(id, name, description, r, g, b) { } GolTool::~GolTool() {} @@ -90,5 +92,14 @@ void GolTool::DrawFill(Simulation * sim, Brush * brush, ui::Point position) { sim->FloodParts(position.X, position.Y, PT_LIFE|(toolID<<8), -1, -1, 0); } - - +void Element_LIGH_Tool::Draw(Simulation * sim, Brush * brush, ui::Point position) +{ + int p = sim->create_part(-2, position.X, position.Y, toolID); + if (p != -1) + { + sim->parts[p].life = brush->GetRadius().X+brush->GetRadius().Y; + if (sim->parts[p].life > 55) + sim->parts[p].life = 55; + sim->parts[p].temp = sim->parts[p].life*150; // temperature of the lighting shows the power of the lighting + } +}
\ No newline at end of file diff --git a/src/game/Tool.h b/src/game/Tool.h index 819620d..2cc33be 100644 --- a/src/game/Tool.h +++ b/src/game/Tool.h @@ -22,9 +22,11 @@ class Tool protected: int toolID; string toolName; + string toolDescription; public: - Tool(int id, string name, int r, int g, int b); + Tool(int id, string name, string description, int r, int g, int b); string GetName(); + string GetDescription(); virtual ~Tool(); virtual void Click(Simulation * sim, Brush * brush, ui::Point position); virtual void Draw(Simulation * sim, Brush * brush, ui::Point position); @@ -38,7 +40,7 @@ class SignTool: public Tool { public: SignTool(): - Tool(0, "SIGN", 0, 0, 0) + Tool(0, "SIGN", "Sign. Click a sign to edit or anywhere else to create a new one", 0, 0, 0) { } virtual ~SignTool() {} @@ -53,7 +55,7 @@ class PropertyTool: public Tool { public: PropertyTool(): - Tool(0, "PROP", 0, 0, 0) + Tool(0, "PROP", "Property Edit. Click to alter the properties of elements in the field", 0, 0, 0) { } virtual ~PropertyTool() {} @@ -64,10 +66,25 @@ public: virtual void DrawFill(Simulation * sim, Brush * brush, ui::Point position) { } }; +class Element_LIGH_Tool: public Tool +{ +public: + Element_LIGH_Tool(int id, string name, string description, int r, int g, int b): + Tool(id, name, description, r, g, b) + { + } + virtual ~Element_LIGH_Tool() {} + virtual void Draw(Simulation * sim, Brush * brush, ui::Point position); + virtual void Click(Simulation * sim, Brush * brush, ui::Point position) { } + virtual void DrawLine(Simulation * sim, Brush * brush, ui::Point position1, ui::Point position2) { } + virtual void DrawRect(Simulation * sim, Brush * brush, ui::Point position1, ui::Point position2) { } + virtual void DrawFill(Simulation * sim, Brush * brush, ui::Point position) { } +}; + class ElementTool: public Tool { public: - ElementTool(int id, string name, int r, int g, int b); + ElementTool(int id, string name, string description, int r, int g, int b); virtual ~ElementTool(); virtual void Draw(Simulation * sim, Brush * brush, ui::Point position); virtual void DrawLine(Simulation * sim, Brush * brush, ui::Point position1, ui::Point position2); @@ -78,7 +95,7 @@ public: class WallTool: public Tool { public: - WallTool(int id, string name, int r, int g, int b); + WallTool(int id, string name, string description, int r, int g, int b); virtual ~WallTool(); virtual void Draw(Simulation * sim, Brush * brush, ui::Point position); virtual void DrawLine(Simulation * sim, Brush * brush, ui::Point position1, ui::Point position2); @@ -89,7 +106,7 @@ public: class GolTool: public Tool { public: - GolTool(int id, string name, int r, int g, int b); + GolTool(int id, string name, string description, int r, int g, int b); 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); diff --git a/src/game/ToolButton.cpp b/src/game/ToolButton.cpp index f1c5583..5c9f2d4 100644 --- a/src/game/ToolButton.cpp +++ b/src/game/ToolButton.cpp @@ -8,8 +8,8 @@ #include "ToolButton.h" #include "interface/Keys.h" -ToolButton::ToolButton(ui::Point position, ui::Point size, std::string text_): - ui::Button(position, size, text_) +ToolButton::ToolButton(ui::Point position, ui::Point size, std::string text_, std::string toolTip): + ui::Button(position, size, text_, toolTip) { SetSelectionState(-1); Appearance.BorderActive = ui::Colour(255, 0, 0); diff --git a/src/game/ToolButton.h b/src/game/ToolButton.h index 94042a9..db0cfac 100644 --- a/src/game/ToolButton.h +++ b/src/game/ToolButton.h @@ -13,7 +13,7 @@ class ToolButton: public ui::Button { int currentSelection; public: - ToolButton(ui::Point position, ui::Point size, std::string text_); + ToolButton(ui::Point position, ui::Point size, std::string text_, std::string toolTip = ""); virtual void OnMouseUp(int x, int y, unsigned int button); virtual void OnMouseClick(int x, int y, unsigned int button); virtual void Draw(const ui::Point& screenPos); |
