summaryrefslogtreecommitdiff
path: root/src/game/GameModel.cpp
diff options
context:
space:
mode:
authorSimon Robertshaw <simon@hardwired.org.uk>2012-04-02 16:01:28 (GMT)
committer Simon Robertshaw <simon@hardwired.org.uk>2012-04-02 16:01:28 (GMT)
commitefddc12e5d2aadc5eee1927245ad38b9dee89aed (patch)
treecf7ad38119f0734609944158e33bbb944925c777 /src/game/GameModel.cpp
parent289556ac7078963b6af361f5812dd62e6712359f (diff)
downloadpowder-efddc12e5d2aadc5eee1927245ad38b9dee89aed.zip
powder-efddc12e5d2aadc5eee1927245ad38b9dee89aed.tar.gz
Stamps browser, placement + clipboard sampling and placement - No clipboard or stamp thumbnail generation, needs thumbnail generator from SaveLoader
Diffstat (limited to 'src/game/GameModel.cpp')
-rw-r--r--src/game/GameModel.cpp54
1 files changed, 43 insertions, 11 deletions
diff --git a/src/game/GameModel.cpp b/src/game/GameModel.cpp
index 0106dd7..2a9b69e 100644
--- a/src/game/GameModel.cpp
+++ b/src/game/GameModel.cpp
@@ -18,7 +18,8 @@ GameModel::GameModel():
currentUser(0, ""),
currentSave(NULL),
colourSelector(false),
- clipboardData(NULL)
+ clipboard(NULL),
+ stamp(NULL)
{
sim = new Simulation();
ren = new Renderer(ui::Engine::Ref().g, sim);
@@ -158,6 +159,10 @@ GameModel::~GameModel()
}
delete sim;
delete ren;
+ if(clipboard)
+ delete clipboard;
+ if(stamp)
+ delete stamp;
if(activeTools)
delete activeTools;
}
@@ -414,23 +419,42 @@ void GameModel::ClearSimulation()
void GameModel::AddStamp(unsigned char * saveData, int saveSize)
{
- //Do nothing
-
- //die alone
+ Save * tempSave = new Save(0, 0, 0, 0, "", "");
+ tempSave->SetData(saveData, saveSize);
+ Client::Ref().AddStamp(tempSave);
+ delete tempSave;
}
void GameModel::SetClipboard(unsigned char * saveData, int saveSize)
{
- if(clipboardData)
- free(clipboardData);
- clipboardData = saveData;
- clipboardSize = saveSize;
+ if(clipboard)
+ delete clipboard;
+ clipboard = new Save(0, 0, 0, 0, "", "");
+ clipboard->SetData(saveData, saveSize);
+ notifyClipboardChanged();
+}
+
+Save * GameModel::GetClipboard()
+{
+ return clipboard;
}
-unsigned char * GameModel::GetClipboard(int & saveSize)
+Save * GameModel::GetStamp()
{
- saveSize = clipboardSize;
- return clipboardData;
+ return stamp;
+}
+
+void GameModel::SetStamp(Save * newStamp)
+{
+ if(stamp)
+ delete stamp;
+ if(newStamp)
+ {
+ stamp = new Save(*newStamp);
+ }
+ else
+ stamp = NULL;
+ notifyStampChanged();
}
void GameModel::notifyColourSelectorColourChanged()
@@ -537,6 +561,14 @@ void GameModel::notifyZoomChanged()
}
}
+void GameModel::notifyStampChanged()
+{
+ for(int i = 0; i < observers.size(); i++)
+ {
+ observers[i]->NotifyStampChanged(this);
+ }
+}
+
void GameModel::notifyClipboardChanged()
{
for(int i = 0; i < observers.size(); i++)