1 #include "GameModeHelper.h"
2 #include "../DasherCore/GameMessages.h"
4 CGameModeHelper::CGameModeHelper(Dasher::CDasherInterfaceBase
*pInterface
) {
5 m_pInterface
= pInterface
;
7 m_strTarget
= "this is a test";
9 m_pInterface
->AddGameModeString(m_strTarget
);
13 void CGameModeHelper::Message(int message
, const void *messagedata
) {
14 using namespace Dasher::GameMode
;
15 const std::string
* pStr
;
16 std::string strText
="<span background=\"purple\" foreground=\"white\">";
18 case GAME_MESSAGE_SET_TARGET_STRING
:
19 pStr
= reinterpret_cast<const std::string
*>(messagedata
);
20 m_strTarget
= (*pStr
);
22 gtk_misc_set_alignment(GTK_MISC(pPrivate->pGameInfoLabel), 0.0, 0.0);
23 gtk_label_set_justify(pPrivate->pGameInfoLabel, GTK_JUSTIFY_CENTER);
24 gtk_label_set_text(pPrivate->pGameInfoLabel, pPrivate->pstrTarget->c_str());
27 case GAME_MESSAGE_DISPLAY_TEXT
:
29 gtk_misc_set_alignment(GTK_MISC(pPrivate->pGameInfoLabel), 0.5, 0.0);
30 gtk_label_set_use_markup(pPrivate->pGameInfoLabel, true);
31 gtk_label_set_justify(pPrivate->pGameInfoLabel, GTK_JUSTIFY_CENTER);
34 strText
+=(reinterpret_cast<const char*>(messagedata
));
37 gtk_label_set_markup(pPrivate->pGameInfoLabel, strText.c_str());
40 case GAME_MESSAGE_EDIT
:
41 pStr
= reinterpret_cast<const std::string
*>(messagedata
);
42 m_strOutput
+= (*pStr
);
45 case GAME_MESSAGE_EDIT_DELETE
:
46 m_strOutput
= m_strOutput
.substr( 0, m_strOutput
.size() -
47 *reinterpret_cast<const int *>(messagedata
));
50 case GAME_MESSAGE_SET_SCORE
:
52 SetScore(pPrivate->pScore, reinterpret_cast<const char*>(messagedata));
55 case GAME_MESSAGE_SET_LEVEL
:
57 gtk_entry_set_text(pPrivate->pLevel, reinterpret_cast<const char*>(messagedata));
60 case GAME_MESSAGE_CLEAR_BUFFER
:
62 dasher_editor_internal_cleartext(pPrivate->pEditor);
66 case GAME_MESSAGE_HELP_MESSAGE
:
67 pStr
= reinterpret_cast<const std::string
*>(messagedata
);
69 game_mode_helper_dialog_box(pSelf, pStr->c_str());
75 void CGameModeHelper::Output(std::string strText
) {
76 m_strOutput
.append(strText
);
78 if(m_strOutput
== m_strTarget
) {
84 void CGameModeHelper::Delete(int iCount
) {
85 m_strOutput
= m_strOutput
.substr(0, m_strOutput
.size() - iCount
);
88 void CGameModeHelper::UpdateTargetLabel()