* Changed "FPS lock:" to "Lock to 30 FPS:" in options, makes it more clear it's actually bad to use and not vsync

* (Windows) Handles alt-tab and clicking on a different monitor while in native fullscreen modes better
* Added "Ghost walk toggle" to in-game cheat menu.  Allows you to walk through solid objects and screenlocks
* (DinkC) Added support for Dan's load_tile() command
* Some junk removed from the debug log

git-svn-id: svn://rtsoft.com/rtsvn/projects/RTDink@1482 353e56fe-9613-0410-8469-b96ad8e6f29c
This commit is contained in:
seth 2017-09-15 14:10:37 +00:00
parent e0717ae8d1
commit ba5fb5abbf
18 changed files with 665 additions and 603 deletions

View file

@ -139,7 +139,7 @@ void AboutMenuOnSelect(VariantList *pVList) //0=vec2 point of click, 1=entity se
}
*/
GetEntityRoot()->PrintTreeAsText(); //useful for debugging
//GetEntityRoot()->PrintTreeAsText(); //useful for debugging
}
void AddBlurb(Entity* pParent, float x, float y, string fileName, string msg)

View file

@ -74,7 +74,7 @@ void BrowseMenuOnSelect(VariantList *pVList) //0=vec2 point of click, 1=entity s
}
*/
GetEntityRoot()->PrintTreeAsText(); //useful for debugging
//GetEntityRoot()->PrintTreeAsText(); //useful for debugging
}

View file

@ -44,7 +44,7 @@ void DMODInstallMenuOnSelect(VariantList *pVList) //0=vec2 point of click, 1=ent
}
GetEntityRoot()->PrintTreeAsText(); //useful for Loading
//GetEntityRoot()->PrintTreeAsText(); //useful for Loading
}
void DMODInstallUpdateStatus(Entity *pMenu, string msg)

View file

@ -156,7 +156,7 @@ void DMODMenuOnSelect(VariantList *pVList) //0=vec2 point of click, 1=entity sen
}
*/
GetEntityRoot()->PrintTreeAsText(); //useful for debugging
//GetEntityRoot()->PrintTreeAsText(); //useful for debugging
}
CL_Vec2f GetDMODBarIconOffset()

View file

@ -1,108 +1,124 @@
#include "PlatformPrecomp.h"
#include "DebugMenu.h"
#include "Entity/EntityUtils.h"
#include "dink/dink.h"
#include "LogMenu.h"
void DebugMenuOnSelect(VariantList *pVList) //0=vec2 point of click, 1=entity sent from
{
Entity *pEntClicked = pVList->m_variant[1].GetEntity();
LogMsg("Clicked %s entity", pEntClicked->GetName().c_str());
if (pEntClicked->GetName() == "FPS")
{
GetBaseApp()->SetFPSVisible(!GetBaseApp()->GetFPSVisible());
}
if (pEntClicked->GetName() == "music_on")
{
GetAudioManager()->Play("audio/intro.ogg", true, true);
}
if (pEntClicked->GetName() == "music_off")
{
GetAudioManager()->StopMusic();
}
if (pEntClicked->GetName() == "log")
{
RemoveFocusIfNeeded(pEntClicked->GetParent());
SlideScreen(pEntClicked->GetParent(), false);
LogMenuCreate(pEntClicked->GetParent()->GetParent());
GetMessageManager()->CallEntityFunction(pEntClicked->GetParent(), 500, "OnDelete", NULL);
}
if (pEntClicked->GetName() == "Back")
{
//slide it off the screen and then kill the whole menu tree
RemoveFocusIfNeeded(pEntClicked->GetParent());
SlideScreen(pEntClicked->GetParent(), false);
AddFocusIfNeeded(pEntClicked->GetParent()->GetParent());
GetMessageManager()->CallEntityFunction(pEntClicked->GetParent(), 500, "OnDelete", NULL);
}
if (pEntClicked->GetName() == "AddStrength")
{
//slide it off the screen and then kill the whole menu tree
DinkModStrength(1);
}
if (pEntClicked->GetName() == "AddDefense")
{
//slide it off the screen and then kill the whole menu tree
DinkModDefense(1);
}
if (pEntClicked->GetName() == "AddMagic")
{
//slide it off the screen and then kill the whole menu tree
DinkModMagic(1);
}
if (pEntClicked->GetName() == "AddLife")
{
//slide it off the screen and then kill the whole menu tree
DinkModLifeMax(10);
}
if (pEntClicked->GetName() == "FillLife")
{
//slide it off the screen and then kill the whole menu tree
DinkFillLife();
}
if (pEntClicked->GetName() == "AddGold")
{
//slide it off the screen and then kill the whole menu tree
DinkModGold(100);
}
if (pEntClicked->GetName() == "empty_cache")
{
DinkUnloadGraphicsCache();
LogMsg("Cache emptied");
}
if (pEntClicked->GetName() == "AddBow")
{
//slide it off the screen and then kill the whole menu tree
DinkAddBow();
}
GetEntityRoot()->PrintTreeAsText(); //useful for debugging
}
Entity * DebugMenuCreate(Entity *pParentEnt)
{
//Entity *pBG = CreateOverlayEntity(pParentEnt, "DebugMenu", "interface/generic_bg.rttex", 0,0);
Entity *pBG = CreateOverlayRectEntity(pParentEnt, CL_Vec2f(0,0), GetScreenSize(), MAKE_RGBA(0,0,0,140));
AddFocusIfNeeded(pBG);
#include "Entity/EntityUtils.h"
#include "dink/dink.h"
#include "LogMenu.h"
#include "GameMenu.h"
void DebugMenuOnSelect(VariantList *pVList) //0=vec2 point of click, 1=entity sent from
{
Entity *pEntClicked = pVList->m_variant[1].GetEntity();
LogMsg("Clicked %s entity", pEntClicked->GetName().c_str());
if (pEntClicked->GetName() == "FPS")
{
GetBaseApp()->SetFPSVisible(!GetBaseApp()->GetFPSVisible());
}
if (pEntClicked->GetName() == "music_on")
{
GetAudioManager()->Play("audio/intro.ogg", true, true);
}
if (pEntClicked->GetName() == "music_off")
{
GetAudioManager()->StopMusic();
}
if (pEntClicked->GetName() == "log")
{
RemoveFocusIfNeeded(pEntClicked->GetParent());
SlideScreen(pEntClicked->GetParent(), false);
LogMenuCreate(pEntClicked->GetParent()->GetParent());
GetMessageManager()->CallEntityFunction(pEntClicked->GetParent(), 500, "OnDelete", NULL);
}
if (pEntClicked->GetName() == "Back")
{
//slide it off the screen and then kill the whole menu tree
RemoveFocusIfNeeded(pEntClicked->GetParent());
SlideScreen(pEntClicked->GetParent(), false);
AddFocusIfNeeded(pEntClicked->GetParent()->GetParent());
GetMessageManager()->CallEntityFunction(pEntClicked->GetParent(), 500, "OnDelete", NULL);
}
if (pEntClicked->GetName() == "AddStrength")
{
//slide it off the screen and then kill the whole menu tree
DinkModStrength(1);
}
if (pEntClicked->GetName() == "AddDefense")
{
//slide it off the screen and then kill the whole menu tree
DinkModDefense(1);
}
if (pEntClicked->GetName() == "AddMagic")
{
//slide it off the screen and then kill the whole menu tree
DinkModMagic(1);
}
if (pEntClicked->GetName() == "AddLife")
{
//slide it off the screen and then kill the whole menu tree
DinkModLifeMax(10);
}
if (pEntClicked->GetName() == "FillLife")
{
//slide it off the screen and then kill the whole menu tree
DinkFillLife();
}
if (pEntClicked->GetName() == "AddGold")
{
//slide it off the screen and then kill the whole menu tree
DinkModGold(100);
}
if (pEntClicked->GetName() == "ghost_walk")
{
GetApp()->SetGhostMode(!GetApp()->GetGhostMode());
if (GetApp()->GetGhostMode())
{
ShowQuickMessage("Ghost walk enabled - can walk through hardness and screenlocks");
}
else
{
ShowQuickMessage("Ghost walk disabled");
}
}
if (pEntClicked->GetName() == "empty_cache")
{
DinkUnloadGraphicsCache();
LogMsg("Cache emptied");
}
if (pEntClicked->GetName() == "AddBow")
{
//slide it off the screen and then kill the whole menu tree
DinkAddBow();
}
//GetEntityRoot()->PrintTreeAsText(); //useful for debugging
}
Entity * DebugMenuCreate(Entity *pParentEnt)
{
//Entity *pBG = CreateOverlayEntity(pParentEnt, "DebugMenu", "interface/generic_bg.rttex", 0,0);
Entity *pBG = CreateOverlayRectEntity(pParentEnt, CL_Vec2f(0,0), GetScreenSize(), MAKE_RGBA(0,0,0,140));
AddFocusIfNeeded(pBG);
Entity *pButtonEntity;
float x = iPhoneMapX(30);
@ -110,54 +126,57 @@ Entity * DebugMenuCreate(Entity *pParentEnt)
float ySpacer = iPhoneMapY(40);
pButtonEntity = CreateTextButtonEntity(pBG, "FPS", x, y, "Toggle FPS Display"); y += ySpacer;
pButtonEntity->GetShared()->GetFunction("OnButtonSelected")->sig_function.connect(&DebugMenuOnSelect);
pButtonEntity->GetShared()->GetFunction("OnButtonSelected")->sig_function.connect(&DebugMenuOnSelect);
//pButtonEntity->GetVar("alignment")->Set(uint32(ALIGNMENT_CENTER));
if (GetApp()->GetCheatsEnabled())
{
if (GetApp()->GetCheatsEnabled())
{
pButtonEntity = CreateTextButtonEntity(pBG, "empty_cache", x, y, "Empty graphic cache"); y += ySpacer;
pButtonEntity->GetShared()->GetFunction("OnButtonSelected")->sig_function.connect(&DebugMenuOnSelect);
}
pButtonEntity->GetShared()->GetFunction("OnButtonSelected")->sig_function.connect(&DebugMenuOnSelect);
pButtonEntity = CreateTextButtonEntity(pBG, "ghost_walk", x, y, "Ghost walk toggle"); y += ySpacer;
pButtonEntity->GetShared()->GetFunction("OnButtonSelected")->sig_function.connect(&DebugMenuOnSelect);
}
pButtonEntity = CreateTextButtonEntity(pBG, "log", x, y, "View log"); y += ySpacer;
pButtonEntity->GetShared()->GetFunction("OnButtonSelected")->sig_function.connect(&DebugMenuOnSelect);
pButtonEntity->GetShared()->GetFunction("OnButtonSelected")->sig_function.connect(&DebugMenuOnSelect);
pButtonEntity = CreateTextButtonEntity(pBG, "Back", x, y, "Back"); y += ySpacer;
pButtonEntity->GetShared()->GetFunction("OnButtonSelected")->sig_function.connect(&DebugMenuOnSelect);
pButtonEntity->GetShared()->GetFunction("OnButtonSelected")->sig_function.connect(&DebugMenuOnSelect);
//pButtonEntity->GetVar("alignment")->Set(uint32(ALIGNMENT_CENTER));
AddHotKeyToButton(pButtonEntity, VIRTUAL_KEY_BACK);
if (GetApp()->GetCheatsEnabled())
if (GetApp()->GetCheatsEnabled())
{
//buttons on right
x = iPhoneMapX(200);
y = iPhoneMapY(30);
pButtonEntity = CreateTextButtonEntity(pBG, "AddStrength", x, y, "Increase Strength"); y += ySpacer;
pButtonEntity->GetShared()->GetFunction("OnButtonSelected")->sig_function.connect(&DebugMenuOnSelect);
pButtonEntity->GetShared()->GetFunction("OnButtonSelected")->sig_function.connect(&DebugMenuOnSelect);
pButtonEntity = CreateTextButtonEntity(pBG, "AddDefense", x, y, "Increase Defense"); y += ySpacer;
pButtonEntity->GetShared()->GetFunction("OnButtonSelected")->sig_function.connect(&DebugMenuOnSelect);
pButtonEntity->GetShared()->GetFunction("OnButtonSelected")->sig_function.connect(&DebugMenuOnSelect);
pButtonEntity = CreateTextButtonEntity(pBG, "AddMagic", x, y, "Increase Magic"); y += ySpacer;
pButtonEntity->GetShared()->GetFunction("OnButtonSelected")->sig_function.connect(&DebugMenuOnSelect);
pButtonEntity->GetShared()->GetFunction("OnButtonSelected")->sig_function.connect(&DebugMenuOnSelect);
pButtonEntity = CreateTextButtonEntity(pBG, "AddLife", x, y, "Increase Life"); y += ySpacer;
pButtonEntity->GetShared()->GetFunction("OnButtonSelected")->sig_function.connect(&DebugMenuOnSelect);
pButtonEntity->GetShared()->GetFunction("OnButtonSelected")->sig_function.connect(&DebugMenuOnSelect);
pButtonEntity = CreateTextButtonEntity(pBG, "FillLife", x, y, "Refill Life"); y += ySpacer;
pButtonEntity->GetShared()->GetFunction("OnButtonSelected")->sig_function.connect(&DebugMenuOnSelect);
pButtonEntity->GetShared()->GetFunction("OnButtonSelected")->sig_function.connect(&DebugMenuOnSelect);
pButtonEntity = CreateTextButtonEntity(pBG, "AddGold", x, y, "Add 100 Gold"); y += ySpacer;
pButtonEntity->GetShared()->GetFunction("OnButtonSelected")->sig_function.connect(&DebugMenuOnSelect);
pButtonEntity->GetShared()->GetFunction("OnButtonSelected")->sig_function.connect(&DebugMenuOnSelect);
pButtonEntity = CreateTextButtonEntity(pBG, "AddBow", x, y, "Add Bow"); y += ySpacer;
pButtonEntity->GetShared()->GetFunction("OnButtonSelected")->sig_function.connect(&DebugMenuOnSelect);
pButtonEntity->GetShared()->GetFunction("OnButtonSelected")->sig_function.connect(&DebugMenuOnSelect);
}
SlideScreen(pBG, true, 500);
return pBG;
}
return pBG;
}

View file

@ -163,7 +163,7 @@ void GameOnSelect(VariantList *pVList) //0=vec2 point of click, 1=entity sent fr
return;
}
GetEntityRoot()->PrintTreeAsText(); //useful for debugging
//GetEntityRoot()->PrintTreeAsText(); //useful for debugging
}
void GameOnStopSelect(VariantList *pVList) //0=vec2 point of click, 1=entity sent from
@ -203,7 +203,7 @@ void GameOnStopSelect(VariantList *pVList) //0=vec2 point of click, 1=entity sen
return;
}
GetEntityRoot()->PrintTreeAsText(); //useful for debugging
//GetEntityRoot()->PrintTreeAsText(); //useful for debugging
}

View file

@ -1,62 +1,62 @@
#include "PlatformPrecomp.h"
#include "LoadMenu.h"
#include "Entity/EntityUtils.h"
#include "MainMenu.h"
#include "dink/dink.h"
#include "GameMenu.h"
#define C_SAVE_GAME_COUNT 10
void LoadMenuOnSelect(VariantList *pVList) //0=vec2 point of click, 1=entity sent from
{
Entity *pEntClicked = pVList->m_variant[1].GetEntity();
LogMsg("Clicked %s entity", pEntClicked->GetName().c_str());
if (pEntClicked->GetName() == "Back")
{
//slide it off the screen and then kill the whole menu tree
SlideScreen(pEntClicked->GetParent(), false);
GetMessageManager()->CallEntityFunction(pEntClicked->GetParent(), 500, "OnDelete", NULL);
MainMenuCreate(pEntClicked->GetParent()->GetParent());
//LoadMenuCreate(GetParent()
}
int num = atol(pEntClicked->GetName().c_str());
if (num > 0)
{
//let's load this sucka
#include "Entity/EntityUtils.h"
#include "MainMenu.h"
#include "dink/dink.h"
#include "GameMenu.h"
#define C_SAVE_GAME_COUNT 10
void LoadMenuOnSelect(VariantList *pVList) //0=vec2 point of click, 1=entity sent from
{
Entity *pEntClicked = pVList->m_variant[1].GetEntity();
LogMsg("Clicked %s entity", pEntClicked->GetName().c_str());
if (pEntClicked->GetName() == "Back")
{
//slide it off the screen and then kill the whole menu tree
SlideScreen(pEntClicked->GetParent(), false);
GetMessageManager()->CallEntityFunction(pEntClicked->GetParent(), 500, "OnDelete", NULL);
MainMenuCreate(pEntClicked->GetParent()->GetParent());
//LoadMenuCreate(GetParent()
}
int num = atol(pEntClicked->GetName().c_str());
if (num > 0)
{
//let's load this sucka
DisableAllButtonsEntity(pEntClicked->GetParent());
SlideScreen(pEntClicked->GetParent(), false);
GetMessageManager()->CallEntityFunction(pEntClicked->GetParent(), 500, "OnDelete", NULL);
GetMessageManager()->CallEntityFunction(pEntClicked->GetParent(), 500, "OnDelete", NULL);
if (num == 10)
{
string fName = GetSavePath()+"dink/"+"autosave.dat";
GameCreate(pEntClicked->GetParent()->GetParent(), 0, fName);
GameCreate(pEntClicked->GetParent()->GetParent(), 0, fName);
} else
{
GameCreate(pEntClicked->GetParent()->GetParent(), num, "");
}
}
GetEntityRoot()->PrintTreeAsText(); //useful for Loading
}
void SetupLoadButton(Entity *pParent, int x, float *pY, int gameID)
{
gameID++; //it's 1 based, not 0 based
const float ySpacer = 46;
if (gameID > 5) x += 200;
char stTemp[256];
char stFormatted[256];
string clickKey = ""; //none
int gameTime;
} else
{
GameCreate(pEntClicked->GetParent()->GetParent(), num, "");
}
}
//GetEntityRoot()->PrintTreeAsText(); //useful for Loading
}
void SetupLoadButton(Entity *pParent, int x, float *pY, int gameID)
{
gameID++; //it's 1 based, not 0 based
const float ySpacer = 46;
if (gameID > 5) x += 200;
char stTemp[256];
char stFormatted[256];
string clickKey = ""; //none
int gameTime;
if (gameID == 10)
{
string autoSave = DinkGetSavePath() + "autosave.dat";
@ -82,27 +82,27 @@ void SetupLoadButton(Entity *pParent, int x, float *pY, int gameID)
sprintf(stFormatted, "Auto Save - %d:%02d - %s", (gameTime / 60), gameTime - ((gameTime / 60) * 60), description.c_str());
clickKey = toString(gameID);
}
} else
if (load_game_small(gameID, stTemp, &gameTime))
{
} else
if (load_game_small(gameID, stTemp, &gameTime))
{
sprintf(stFormatted, "Slot %d - %d:%02d - %s", gameID, (gameTime / 60), gameTime - ((gameTime / 60) * 60) , stTemp);
clickKey = toString(gameID);
} else
{
sprintf(stFormatted, "Slot %d - Empty", gameID);
}
string butText = stFormatted;
} else
{
sprintf(stFormatted, "Slot %d - Empty", gameID);
}
string butText = stFormatted;
Entity * pButtonEntity = CreateTextButtonEntity(pParent, clickKey, iPhoneMapX(x), iPhoneMapY(*pY), butText, false); *pY += ySpacer;
pButtonEntity->GetShared()->GetFunction("OnButtonSelected")->sig_function.connect(&LoadMenuOnSelect);
pButtonEntity->GetShared()->GetFunction("OnButtonSelected")->sig_function.connect(&LoadMenuOnSelect);
//pButtonEntity->GetVar("alignment")->Set(uint32(ALIGNMENT_CENTER));
}
Entity * LoadMenuCreate(Entity *pParentEnt)
{
Entity *pBG = CreateOverlayEntity(pParentEnt, "LoadMenu", ReplaceWithDeviceNameInFileName("interface/iphone/bkgd_stone.rttex"), 0,0);
AddFocusIfNeeded(pBG, true);
}
Entity * LoadMenuCreate(Entity *pParentEnt)
{
Entity *pBG = CreateOverlayEntity(pParentEnt, "LoadMenu", ReplaceWithDeviceNameInFileName("interface/iphone/bkgd_stone.rttex"), 0,0);
AddFocusIfNeeded(pBG, true);
Entity *pButtonEntity;
float x = 80;
@ -116,12 +116,12 @@ Entity * LoadMenuCreate(Entity *pParentEnt)
SetupLoadButton(pBG, x, &y, i);
}
pButtonEntity = CreateTextButtonEntity(pBG, "Back", iPhoneMapX(x), iPhoneMapY(y), "Back"); y += ySpacer;
pButtonEntity->GetShared()->GetFunction("OnButtonSelected")->sig_function.connect(&LoadMenuOnSelect);
pButtonEntity->GetShared()->GetFunction("OnButtonSelected")->sig_function.connect(&LoadMenuOnSelect);
//pButtonEntity->GetVar("alignment")->Set(uint32(ALIGNMENT_CENTER));
SlideScreen(pBG, true, 500);
return pBG;
}
return pBG;
}

View file

@ -1,98 +1,98 @@
#include "PlatformPrecomp.h"
#include "LogMenu.h"
#include "Entity/EntityUtils.h"
#include "dink/dink.h"
#include "MainMenu.h"
void LogEnd(Entity *pMenu)
{
//slide it off the screen and then kill the whole menu tree
RemoveFocusIfNeeded(pMenu);
//SlideScreen(pEntClicked->GetParent(), false);
AddFocusIfNeeded(pMenu->GetParent());
FadeOutEntity(pMenu, true, 499);
GetMessageManager()->CallEntityFunction(pMenu, 500, "OnDelete", NULL);
}
void LogMenuOnSelect(VariantList *pVList) //0=vec2 point of click, 1=entity sent from
{
Entity *pEntClicked = pVList->m_variant[1].GetEntity();
LogMsg("Clicked %s entity", pEntClicked->GetName().c_str());
Entity *pMenu = GetEntityRoot()->GetEntityByName("LogMenu");
if (pEntClicked->GetName() == "Back")
{
LogEnd(pMenu);
}
GetEntityRoot()->PrintTreeAsText(); //useful for Log
}
void LogAddScrollContent(Entity *pParent)
{
pParent = pParent->GetEntityByName("scroll_child");
float x = iPhoneMapX(5);
float y = 0;
CL_Vec2f vTextBoxPos(iPhoneMapX(20),y);
CL_Vec2f vTextBounds(iPhoneMapX(434), iPhoneMapY(200));
string msg = GetBaseApp()->GetConsole()->GetAsSingleString();
CreateTextBoxEntity(pParent, "", vTextBoxPos, vTextBounds, msg, 0.7f);
VariantList vList(pParent->GetParent());
ResizeScrollBounds(&vList);
}
Entity * LogMenuCreate(Entity *pParentEnt)
{
Entity *pBG = CreateOverlayRectEntity(pParentEnt, CL_Vec2f(0,0), GetScreenSize(), MAKE_RGBA(0,0,0,140));
pBG->SetName("LogMenu");
AddFocusIfNeeded(pBG, true);
Entity *pButtonEntity;
//setup a scrolling window
CL_Vec2f vTextAreaPos = CL_Vec2f(0,0);
float offsetFromBottom = iPhoneMapY(30);
CL_Vec2f vTextAreaBounds = GetScreenSize()-CL_Vec2f(15,offsetFromBottom);
Entity *pScroll = pBG->AddEntity(new Entity("scroll"));
pScroll->GetVar("size2d")->Set(vTextAreaBounds);
pScroll->AddComponent(new TouchHandlerComponent);
EntityComponent *pFilter = pScroll->AddComponent(new FilterInputComponent);
EntityComponent *pScrollComp = pScroll->AddComponent(new ScrollComponent);
EntityComponent *pScrollBarComp = pScroll->AddComponent(new ScrollBarRenderComponent); //also let's add a visual way to see the scroller position
pScroll->GetVar("color")->Set(MAKE_RGBA(61,155, 193, 255));
Entity *pScrollChild = pScroll->AddEntity(new Entity("scroll_child"));
#include "PlatformPrecomp.h"
#include "LogMenu.h"
#include "Entity/EntityUtils.h"
#include "dink/dink.h"
#include "MainMenu.h"
void LogEnd(Entity *pMenu)
{
//slide it off the screen and then kill the whole menu tree
RemoveFocusIfNeeded(pMenu);
//SlideScreen(pEntClicked->GetParent(), false);
AddFocusIfNeeded(pMenu->GetParent());
FadeOutEntity(pMenu, true, 499);
GetMessageManager()->CallEntityFunction(pMenu, 500, "OnDelete", NULL);
}
void LogMenuOnSelect(VariantList *pVList) //0=vec2 point of click, 1=entity sent from
{
Entity *pEntClicked = pVList->m_variant[1].GetEntity();
LogMsg("Clicked %s entity", pEntClicked->GetName().c_str());
Entity *pMenu = GetEntityRoot()->GetEntityByName("LogMenu");
if (pEntClicked->GetName() == "Back")
{
LogEnd(pMenu);
}
//GetEntityRoot()->PrintTreeAsText(); //useful for Log
}
void LogAddScrollContent(Entity *pParent)
{
pParent = pParent->GetEntityByName("scroll_child");
float x = iPhoneMapX(5);
float y = 0;
CL_Vec2f vTextBoxPos(iPhoneMapX(20),y);
CL_Vec2f vTextBounds(iPhoneMapX(434), iPhoneMapY(200));
string msg = GetBaseApp()->GetConsole()->GetAsSingleString();
CreateTextBoxEntity(pParent, "", vTextBoxPos, vTextBounds, msg, 0.7f);
VariantList vList(pParent->GetParent());
ResizeScrollBounds(&vList);
}
Entity * LogMenuCreate(Entity *pParentEnt)
{
Entity *pBG = CreateOverlayRectEntity(pParentEnt, CL_Vec2f(0,0), GetScreenSize(), MAKE_RGBA(0,0,0,140));
pBG->SetName("LogMenu");
AddFocusIfNeeded(pBG, true);
Entity *pButtonEntity;
//setup a scrolling window
CL_Vec2f vTextAreaPos = CL_Vec2f(0,0);
float offsetFromBottom = iPhoneMapY(30);
CL_Vec2f vTextAreaBounds = GetScreenSize()-CL_Vec2f(15,offsetFromBottom);
Entity *pScroll = pBG->AddEntity(new Entity("scroll"));
pScroll->GetVar("size2d")->Set(vTextAreaBounds);
pScroll->AddComponent(new TouchHandlerComponent);
EntityComponent *pFilter = pScroll->AddComponent(new FilterInputComponent);
EntityComponent *pScrollComp = pScroll->AddComponent(new ScrollComponent);
EntityComponent *pScrollBarComp = pScroll->AddComponent(new ScrollBarRenderComponent); //also let's add a visual way to see the scroller position
pScroll->GetVar("color")->Set(MAKE_RGBA(61,155, 193, 255));
Entity *pScrollChild = pScroll->AddEntity(new Entity("scroll_child"));
pScrollComp->GetVar("fingerTracking")->Set(uint32(1));
EntityComponent *pClip = pScroll->AddComponent(new RenderClipComponent);
pClip->GetVar("clipMode")->Set(uint32(RenderClipComponent::CLIP_MODE_BOTTOM));
//Entity *pOverlay = CreateOverlayEntity(pBG, "", ReplaceWithDeviceNameInFileName("interface/iphone/bg_stone_overlay.rttex"), 0, GetScreenSizeYf());
//SetAlignmentEntity(pOverlay, ALIGNMENT_DOWN_LEFT);
LogAddScrollContent(pBG);
VariantList vList(CL_Vec2f(0.0f, 1.0f));
pScrollComp->GetFunction("SetProgress")->sig_function(&vList); //scroll to the end
pButtonEntity = CreateTextButtonEntity(pBG, "Back", iPhoneMapX(35), iPhoneMapY(300), "CONTINUE", false);
pButtonEntity->GetShared()->GetFunction("OnButtonSelected")->sig_function.connect(&LogMenuOnSelect);
pButtonEntity->GetVar("alignment")->Set(uint32(ALIGNMENT_CENTER));
AddHotKeyToButton(pButtonEntity, VIRTUAL_KEY_BACK);
FadeInEntity(pBG, true);
return pBG;
}
EntityComponent *pClip = pScroll->AddComponent(new RenderClipComponent);
pClip->GetVar("clipMode")->Set(uint32(RenderClipComponent::CLIP_MODE_BOTTOM));
//Entity *pOverlay = CreateOverlayEntity(pBG, "", ReplaceWithDeviceNameInFileName("interface/iphone/bg_stone_overlay.rttex"), 0, GetScreenSizeYf());
//SetAlignmentEntity(pOverlay, ALIGNMENT_DOWN_LEFT);
LogAddScrollContent(pBG);
VariantList vList(CL_Vec2f(0.0f, 1.0f));
pScrollComp->GetFunction("SetProgress")->sig_function(&vList); //scroll to the end
pButtonEntity = CreateTextButtonEntity(pBG, "Back", iPhoneMapX(35), iPhoneMapY(300), "CONTINUE", false);
pButtonEntity->GetShared()->GetFunction("OnButtonSelected")->sig_function.connect(&LogMenuOnSelect);
pButtonEntity->GetVar("alignment")->Set(uint32(ALIGNMENT_CENTER));
AddHotKeyToButton(pButtonEntity, VIRTUAL_KEY_BACK);
FadeInEntity(pBG, true);
return pBG;
}

View file

@ -279,7 +279,7 @@ void OptionsMenuOnSelect(VariantList *pVList) //0=vec2 point of click, 1=entity
return;
}
GetEntityRoot()->PrintTreeAsText(); //useful for debugging
//GetEntityRoot()->PrintTreeAsText(); //useful for debugging
}
@ -479,7 +479,7 @@ void OptionsMenuAddScrollContent(Entity *pParent)
//fps limit
pEnt = CreateTextLabelEntity(pBG, "", startX, y, "FPS lock:");
pEnt = CreateTextLabelEntity(pBG, "", startX, y, "Lock to 30 FPS:");
SetupTextEntity(pEnt,fontID);
offsetX = iPhoneMapX(columnX);
pEnt = CreateTextButtonEntity(pBG, "fps_limit_0", offsetX, y, "On", false);

View file

@ -232,7 +232,7 @@ void PauseMenuOnSelect(VariantList *pVList) //0=vec2 point of click, 1=entity se
}
GetEntityRoot()->PrintTreeAsText(); //useful for Pause
//GetEntityRoot()->PrintTreeAsText(); //useful for Pause
}

View file

@ -1,251 +1,251 @@
#include "PlatformPrecomp.h"
#include "PopUpMenu.h"
#include "Entity/EntityUtils.h"
#include "App.h"
Entity * PopUpRestoreFocusToOriginalMenu(Entity *pEntClicked)
{
Entity *pFinishMenu = GetEntityRoot()->GetEntityByName(pEntClicked->GetParent()->GetParent()->GetVar("finishMenuName")->GetString());
assert(pFinishMenu);
if (pFinishMenu)
{
if (pEntClicked->GetParent()->GetParent()->GetVar("requireMoveMessages")->GetUINT32() == 1)
{
AddFocusIfNeeded(pFinishMenu, true, 0);
} else
{
pFinishMenu->AddComponent(new FocusInputComponent);
}
}
return pFinishMenu;
}
void ReloadMainMenu(VariantList *pVList);
//general purpose pop up menu, I've hardcoded various behaviors here, it knows what to do based on the button name
void PopUpMenuOnSelect(VariantList *pVList) //0=vec2 point of click, 1=entity sent from
{
Entity *pEntClicked = pVList->m_variant[1].GetEntity();
LogMsg("Clicked %s entity at %s", pEntClicked->GetName().c_str(),pVList->m_variant[1].Print().c_str());
FadeOutEntity(pEntClicked->GetParent()->GetParent(), true, 300);
GetMessageManager()->CallEntityFunction(pEntClicked->GetParent()->GetParent(), 500, "OnDelete", NULL);
DisableAllButtonsEntity(pEntClicked->GetParent()->GetParent());
Entity *pDarken = GetEntityRoot()->GetEntityByName("pop_up_darken");
FadeScreen(pDarken, 0, 0, 400, true);
KillEntity(pDarken, 400);
pDarken->SetName("");
//set the game pause state back to whatever it was originally
GetApp()->SetGameTickPause(pEntClicked->GetParent()->GetParent()->GetVar("gamePaused")->GetUINT32() != 0);
if (pEntClicked->GetName() == "url")
{
LogMsg("Launch url: %s", pEntClicked->GetVar("url")->GetString().c_str());
LaunchURL(pEntClicked->GetVar("url")->GetString());
Entity *pFinishMenu = PopUpRestoreFocusToOriginalMenu(pEntClicked);
} else if (pEntClicked->GetName() == "url_update")
{
LogMsg("Launch url: %s", pEntClicked->GetVar("url")->GetString().c_str());
LaunchURL(pEntClicked->GetVar("url")->GetString());
Entity *pFinishMenu = PopUpRestoreFocusToOriginalMenu(pEntClicked);
//kill current menu
//GetMessageManager()->CallEntityFunction(pFinishMenu, 200, "OnDelete", NULL);
PopUpCreate(pFinishMenu, "Please close the game and install the new version!", "", "cancel", "", "", "", true);
}
else
/*
if (pEntClicked->GetName() == "music_disable")
{
//add control back
Entity *pFinishMenu = PopUpRestoreFocusToOriginalMenu(pEntClicked);
GetApp()->GetShared()->GetVar("musicDisabled")->Set(uint32(1));
GetAudioManager()->SetMusicEnabled(false);
string msg = "Music disabled. You can re-enable it from the `wOptions`` menu later.";
PopUpCreate(pFinishMenu, msg, "", "cancel", "Continue", "", "", true);
GetAudioManager()->Play(GetApp()->GetMainMenuMusic(), true, true); //because music is disabled this won't play, but it will remember this if
//we enable music again so we still want it
} else
if (pEntClicked->GetName() == "music_on")
{
//add control back
Entity *pFinishMenu = PopUpRestoreFocusToOriginalMenu(pEntClicked);
GetAudioManager()->Play(GetApp()->GetMainMenuMusic(), true, true);
} else
if (pEntClicked->GetName() == "quit_game")
{
Entity *pGameMenu = GetEntityRoot()->GetEntityByName("GameMenu");
//GetApp()->SetGameType(GAME_TYPE_NONE);
//slide it off the screen and then kill the whole menu tree
SlideScreen(pGameMenu, false, 500, 10);
GetMessageManager()->CallEntityFunction(pGameMenu, 900, "OnDelete", NULL);
//SummaryMenuCreate(pGameMenu->GetParent());
GetBaseApp()->SetGameTickPause(false);
} else
*/
if (pEntClicked->GetName() == "cancel")
{
//add control back
Entity *pFinishMenu = PopUpRestoreFocusToOriginalMenu(pEntClicked);
}if (pEntClicked->GetName() == "cancel_update")
{
//add control back
Entity *pFinishMenu = PopUpRestoreFocusToOriginalMenu(pEntClicked);
//kill current menu
GetMessageManager()->CallEntityFunction(pFinishMenu, 100, "OnDelete", NULL);
#include "PlatformPrecomp.h"
#include "PopUpMenu.h"
#include "Entity/EntityUtils.h"
#include "App.h"
Entity * PopUpRestoreFocusToOriginalMenu(Entity *pEntClicked)
{
Entity *pFinishMenu = GetEntityRoot()->GetEntityByName(pEntClicked->GetParent()->GetParent()->GetVar("finishMenuName")->GetString());
assert(pFinishMenu);
if (pFinishMenu)
{
if (pEntClicked->GetParent()->GetParent()->GetVar("requireMoveMessages")->GetUINT32() == 1)
{
AddFocusIfNeeded(pFinishMenu, true, 0);
} else
{
pFinishMenu->AddComponent(new FocusInputComponent);
}
}
return pFinishMenu;
}
void ReloadMainMenu(VariantList *pVList);
//general purpose pop up menu, I've hardcoded various behaviors here, it knows what to do based on the button name
void PopUpMenuOnSelect(VariantList *pVList) //0=vec2 point of click, 1=entity sent from
{
Entity *pEntClicked = pVList->m_variant[1].GetEntity();
LogMsg("Clicked %s entity at %s", pEntClicked->GetName().c_str(),pVList->m_variant[1].Print().c_str());
FadeOutEntity(pEntClicked->GetParent()->GetParent(), true, 300);
GetMessageManager()->CallEntityFunction(pEntClicked->GetParent()->GetParent(), 500, "OnDelete", NULL);
DisableAllButtonsEntity(pEntClicked->GetParent()->GetParent());
Entity *pDarken = GetEntityRoot()->GetEntityByName("pop_up_darken");
FadeScreen(pDarken, 0, 0, 400, true);
KillEntity(pDarken, 400);
pDarken->SetName("");
//set the game pause state back to whatever it was originally
GetApp()->SetGameTickPause(pEntClicked->GetParent()->GetParent()->GetVar("gamePaused")->GetUINT32() != 0);
if (pEntClicked->GetName() == "url")
{
LogMsg("Launch url: %s", pEntClicked->GetVar("url")->GetString().c_str());
LaunchURL(pEntClicked->GetVar("url")->GetString());
Entity *pFinishMenu = PopUpRestoreFocusToOriginalMenu(pEntClicked);
} else if (pEntClicked->GetName() == "url_update")
{
LogMsg("Launch url: %s", pEntClicked->GetVar("url")->GetString().c_str());
LaunchURL(pEntClicked->GetVar("url")->GetString());
Entity *pFinishMenu = PopUpRestoreFocusToOriginalMenu(pEntClicked);
//kill current menu
//GetMessageManager()->CallEntityFunction(pFinishMenu, 200, "OnDelete", NULL);
PopUpCreate(pFinishMenu, "Please close the game and install the new version!", "", "cancel", "", "", "", true);
}
else
/*
if (pEntClicked->GetName() == "music_disable")
{
//add control back
Entity *pFinishMenu = PopUpRestoreFocusToOriginalMenu(pEntClicked);
GetApp()->GetShared()->GetVar("musicDisabled")->Set(uint32(1));
GetAudioManager()->SetMusicEnabled(false);
string msg = "Music disabled. You can re-enable it from the `wOptions`` menu later.";
PopUpCreate(pFinishMenu, msg, "", "cancel", "Continue", "", "", true);
GetAudioManager()->Play(GetApp()->GetMainMenuMusic(), true, true); //because music is disabled this won't play, but it will remember this if
//we enable music again so we still want it
} else
if (pEntClicked->GetName() == "music_on")
{
//add control back
Entity *pFinishMenu = PopUpRestoreFocusToOriginalMenu(pEntClicked);
GetAudioManager()->Play(GetApp()->GetMainMenuMusic(), true, true);
} else
if (pEntClicked->GetName() == "quit_game")
{
Entity *pGameMenu = GetEntityRoot()->GetEntityByName("GameMenu");
//GetApp()->SetGameType(GAME_TYPE_NONE);
//slide it off the screen and then kill the whole menu tree
SlideScreen(pGameMenu, false, 500, 10);
GetMessageManager()->CallEntityFunction(pGameMenu, 900, "OnDelete", NULL);
//SummaryMenuCreate(pGameMenu->GetParent());
GetBaseApp()->SetGameTickPause(false);
} else
*/
if (pEntClicked->GetName() == "cancel")
{
//add control back
Entity *pFinishMenu = PopUpRestoreFocusToOriginalMenu(pEntClicked);
}if (pEntClicked->GetName() == "cancel_update")
{
//add control back
Entity *pFinishMenu = PopUpRestoreFocusToOriginalMenu(pEntClicked);
//kill current menu
GetMessageManager()->CallEntityFunction(pFinishMenu, 100, "OnDelete", NULL);
VariantList vList(pFinishMenu->GetParent());
GetMessageManager()->CallStaticFunction(ReloadMainMenu, 200, &vList, TIMER_SYSTEM);
}
else
if (pEntClicked->GetName() == "reset")
{
//add control back
Entity *pFinishMenu = PopUpRestoreFocusToOriginalMenu(pEntClicked);
GetAudioManager()->Play("audio/tip_start.wav");
//GetHighScoreManager()->ResetLocalScores();
//belay that order, show another pop up...
PopUpCreate(pFinishMenu, "Local high scores have been reset.", "", "cancel", "Continue", "", "", true);
} else
{
//unhandled
Entity *pFinishMenu = PopUpRestoreFocusToOriginalMenu(pEntClicked);
//call this function on the original guy, just in case they want to do something with it
VariantList vList(pFinishMenu, pEntClicked->GetName());
pFinishMenu->GetFunction(pEntClicked->GetName())->sig_function(&vList);
}
GetEntityRoot()->PrintTreeAsText(); //useful for debugging
}
void PopUpCreate(Entity *pEnt, string msg, string url, string button1Action, string button1Label, string button2Action, string button2Label,
bool bRequireMoveMessages, string button3Action, string button3Label)
{
pEnt->RemoveComponentByName("FocusInput");
bool bGamePaused = GetBaseApp()->GetGameTickPause();
GetBaseApp()->SetGameTickPause(true);
// GetMessageManager()->RemoveComponentByName(pEnt, 201, "FocusInput"); //hack that works around a problem of pending FocusInput messages coming in
//remember where we should give focus to later
string parentName = pEnt->GetName();
assert(!parentName.empty());
//let's build our own menu right on the GUI branch of the tree
pEnt = GetEntityRoot()->GetEntityByName("GUI");
Entity *pDarken = pEnt->AddEntity(new Entity("pop_up_darken"));
pDarken->AddComponent(new FocusRenderComponent);
pDarken->AddComponent(new FocusUpdateComponent);
FadeScreen(pDarken, 0, 0.7, 400, false); //fade the whole GUI
//add our prompt
Entity *pBG = CreateOverlayEntity(pEnt, "pop_up", ReplaceWithLargeInFileName("interface/iphone/pop_up.rttex"), 0,0);
//Ok, at this point we can check the image dimensions and center it based on the bitmap size itself
pBG->GetVar("pos2d")->Set( (GetScreenSize()/2) - pBG->GetVar("size2d")->GetVector2()/2);
// pBG->AddComponent(new FocusInputComponent);
pBG->GetVar("finishMenuName")->Set(parentName);
if (bRequireMoveMessages)
{
pBG->GetVar("requireMoveMessages")->Set(uint32(1));
}
AddFocusIfNeeded(pBG);
CL_Vec2f vTextArea = pBG->GetVar("size2d")->GetVector2();
float padding = 30;
vTextArea.x -= iPhoneMapX2X(padding*2);
//add our msg and word wrap it
Entity *pText = CreateTextBoxEntity(pBG, "pop_up_text", (pBG->GetVar("size2d")->GetVector2()/2)+CL_Vec2f(0, iPhoneMapY2X(-17)), vTextArea, msg);
SetAlignmentEntity(pText, ALIGNMENT_CENTER);
float textHeight = pText->GetVar("size2d")->GetVector2().y;
FadeInEntity(pBG, true, 300);
//pText->GetVar("color")->Set(MAKE_RGBA(203,177,137,255));
pBG->GetVar("gamePaused")->Set(uint32(bGamePaused != 0)); //remember this for later
Entity *pButton = NULL;
CL_Vec2f vButtonSize;
Entity *pLabel;
Entity *pButton1, *pButton2;
float buttonHeight = iPhoneMapY2X(120);
if (textHeight > iPhoneMapY2X(50))
{
//well, we need more space for this much text. Move the buttons down a bit.
buttonHeight = iPhoneMapY2X(135);
}
//add the buttons
pButton = CreateOverlayEntity(pBG, "button1", ReplaceWithLargeInFileName("interface/iphone/pop_up_button.rttex"), iPhoneMapX2X(21), buttonHeight);
pButton1 = pButton;
vButtonSize = pButton->GetVar("size2d")->GetVector2();
//add the text label
pLabel = CreateTextButtonEntity(pButton, button1Action, vButtonSize.x/2, vButtonSize.y/2, "`w"+button1Label, false);
pLabel->GetVar("alignment")->Set(uint32(ALIGNMENT_CENTER));
pLabel->GetFunction("OnButtonSelected")->sig_function.connect(&PopUpMenuOnSelect);
pLabel->GetVar("url")->Set(url); //just in case we want to know this later, store it in the button itself
FadeInEntity(pButton, true, 300, 250);
if (button2Label.empty())
{
//we only have one button? Fine, center it.
pButton->GetVar("pos2d")->Set(iPhoneMapX(88), buttonHeight);
} else
{
pButton = CreateOverlayEntity(pBG, "button2", ReplaceWithLargeInFileName("interface/iphone/pop_up_button.rttex"), iPhoneMapY2X(180), buttonHeight);
pButton2 = pButton;
vButtonSize = pButton->GetVar("size2d")->GetVector2();
//add the text label
pLabel = CreateTextButtonEntity(pButton, button2Action, vButtonSize.x/2, vButtonSize.y/2, "`w"+button2Label, false);
pLabel->GetVar("alignment")->Set(uint32(ALIGNMENT_CENTER));
pLabel->GetFunction("OnButtonSelected")->sig_function.connect(&PopUpMenuOnSelect);
pLabel->GetVar("url")->Set(url); //just in case we want to know this later, store it in the button itself
FadeInEntity(pButton, true, 300, 350);
if (button3Label.empty())
{
//we only have two buttons? fine. Done then
} else
{
pButton1->GetVar("pos2d")->Set(iPhoneMapX2X(20), buttonHeight);
pButton2->GetVar("pos2d")->Set(iPhoneMapX2X(180), buttonHeight);
//move stuff around and add a third button
pButton = CreateOverlayEntity(pBG, "button2", ReplaceWithLargeInFileName("interface/iphone/pop_up_button.rttex"), iPhoneMapX2X(100), buttonHeight);
vButtonSize = pButton->GetVar("size2d")->GetVector2();
//add the text label
pLabel = CreateTextButtonEntity(pButton, button3Action, vButtonSize.x/2, vButtonSize.y/2, "`w"+button3Label, false);
pLabel->GetVar("alignment")->Set(uint32(ALIGNMENT_CENTER));
pLabel->GetFunction("OnButtonSelected")->sig_function.connect(&PopUpMenuOnSelect);
pLabel->GetVar("url")->Set(url); //just in case we want to know this later, store it in the button itself
FadeInEntity(pButton, true, 300, 450);
}
}
GetEntityRoot()->PrintTreeAsText(); //useful for debugging
}
GetMessageManager()->CallStaticFunction(ReloadMainMenu, 200, &vList, TIMER_SYSTEM);
}
else
if (pEntClicked->GetName() == "reset")
{
//add control back
Entity *pFinishMenu = PopUpRestoreFocusToOriginalMenu(pEntClicked);
GetAudioManager()->Play("audio/tip_start.wav");
//GetHighScoreManager()->ResetLocalScores();
//belay that order, show another pop up...
PopUpCreate(pFinishMenu, "Local high scores have been reset.", "", "cancel", "Continue", "", "", true);
} else
{
//unhandled
Entity *pFinishMenu = PopUpRestoreFocusToOriginalMenu(pEntClicked);
//call this function on the original guy, just in case they want to do something with it
VariantList vList(pFinishMenu, pEntClicked->GetName());
pFinishMenu->GetFunction(pEntClicked->GetName())->sig_function(&vList);
}
//GetEntityRoot()->PrintTreeAsText(); //useful for debugging
}
void PopUpCreate(Entity *pEnt, string msg, string url, string button1Action, string button1Label, string button2Action, string button2Label,
bool bRequireMoveMessages, string button3Action, string button3Label)
{
pEnt->RemoveComponentByName("FocusInput");
bool bGamePaused = GetBaseApp()->GetGameTickPause();
GetBaseApp()->SetGameTickPause(true);
// GetMessageManager()->RemoveComponentByName(pEnt, 201, "FocusInput"); //hack that works around a problem of pending FocusInput messages coming in
//remember where we should give focus to later
string parentName = pEnt->GetName();
assert(!parentName.empty());
//let's build our own menu right on the GUI branch of the tree
pEnt = GetEntityRoot()->GetEntityByName("GUI");
Entity *pDarken = pEnt->AddEntity(new Entity("pop_up_darken"));
pDarken->AddComponent(new FocusRenderComponent);
pDarken->AddComponent(new FocusUpdateComponent);
FadeScreen(pDarken, 0, 0.7, 400, false); //fade the whole GUI
//add our prompt
Entity *pBG = CreateOverlayEntity(pEnt, "pop_up", ReplaceWithLargeInFileName("interface/iphone/pop_up.rttex"), 0,0);
//Ok, at this point we can check the image dimensions and center it based on the bitmap size itself
pBG->GetVar("pos2d")->Set( (GetScreenSize()/2) - pBG->GetVar("size2d")->GetVector2()/2);
// pBG->AddComponent(new FocusInputComponent);
pBG->GetVar("finishMenuName")->Set(parentName);
if (bRequireMoveMessages)
{
pBG->GetVar("requireMoveMessages")->Set(uint32(1));
}
AddFocusIfNeeded(pBG);
CL_Vec2f vTextArea = pBG->GetVar("size2d")->GetVector2();
float padding = 30;
vTextArea.x -= iPhoneMapX2X(padding*2);
//add our msg and word wrap it
Entity *pText = CreateTextBoxEntity(pBG, "pop_up_text", (pBG->GetVar("size2d")->GetVector2()/2)+CL_Vec2f(0, iPhoneMapY2X(-17)), vTextArea, msg);
SetAlignmentEntity(pText, ALIGNMENT_CENTER);
float textHeight = pText->GetVar("size2d")->GetVector2().y;
FadeInEntity(pBG, true, 300);
//pText->GetVar("color")->Set(MAKE_RGBA(203,177,137,255));
pBG->GetVar("gamePaused")->Set(uint32(bGamePaused != 0)); //remember this for later
Entity *pButton = NULL;
CL_Vec2f vButtonSize;
Entity *pLabel;
Entity *pButton1, *pButton2;
float buttonHeight = iPhoneMapY2X(120);
if (textHeight > iPhoneMapY2X(50))
{
//well, we need more space for this much text. Move the buttons down a bit.
buttonHeight = iPhoneMapY2X(135);
}
//add the buttons
pButton = CreateOverlayEntity(pBG, "button1", ReplaceWithLargeInFileName("interface/iphone/pop_up_button.rttex"), iPhoneMapX2X(21), buttonHeight);
pButton1 = pButton;
vButtonSize = pButton->GetVar("size2d")->GetVector2();
//add the text label
pLabel = CreateTextButtonEntity(pButton, button1Action, vButtonSize.x/2, vButtonSize.y/2, "`w"+button1Label, false);
pLabel->GetVar("alignment")->Set(uint32(ALIGNMENT_CENTER));
pLabel->GetFunction("OnButtonSelected")->sig_function.connect(&PopUpMenuOnSelect);
pLabel->GetVar("url")->Set(url); //just in case we want to know this later, store it in the button itself
FadeInEntity(pButton, true, 300, 250);
if (button2Label.empty())
{
//we only have one button? Fine, center it.
pButton->GetVar("pos2d")->Set(iPhoneMapX(88), buttonHeight);
} else
{
pButton = CreateOverlayEntity(pBG, "button2", ReplaceWithLargeInFileName("interface/iphone/pop_up_button.rttex"), iPhoneMapY2X(180), buttonHeight);
pButton2 = pButton;
vButtonSize = pButton->GetVar("size2d")->GetVector2();
//add the text label
pLabel = CreateTextButtonEntity(pButton, button2Action, vButtonSize.x/2, vButtonSize.y/2, "`w"+button2Label, false);
pLabel->GetVar("alignment")->Set(uint32(ALIGNMENT_CENTER));
pLabel->GetFunction("OnButtonSelected")->sig_function.connect(&PopUpMenuOnSelect);
pLabel->GetVar("url")->Set(url); //just in case we want to know this later, store it in the button itself
FadeInEntity(pButton, true, 300, 350);
if (button3Label.empty())
{
//we only have two buttons? fine. Done then
} else
{
pButton1->GetVar("pos2d")->Set(iPhoneMapX2X(20), buttonHeight);
pButton2->GetVar("pos2d")->Set(iPhoneMapX2X(180), buttonHeight);
//move stuff around and add a third button
pButton = CreateOverlayEntity(pBG, "button2", ReplaceWithLargeInFileName("interface/iphone/pop_up_button.rttex"), iPhoneMapX2X(100), buttonHeight);
vButtonSize = pButton->GetVar("size2d")->GetVector2();
//add the text label
pLabel = CreateTextButtonEntity(pButton, button3Action, vButtonSize.x/2, vButtonSize.y/2, "`w"+button3Label, false);
pLabel->GetVar("alignment")->Set(uint32(ALIGNMENT_CENTER));
pLabel->GetFunction("OnButtonSelected")->sig_function.connect(&PopUpMenuOnSelect);
pLabel->GetVar("url")->Set(url); //just in case we want to know this later, store it in the button itself
FadeInEntity(pButton, true, 300, 450);
}
}
//GetEntityRoot()->PrintTreeAsText(); //useful for debugging
}

View file

@ -11,7 +11,7 @@ void QuickTipMenuOnSelect(VariantList *pVList) //0=vec2 point of click, 1=entity
GetAudioManager()->Play("audio/tip_end.wav");
LogMsg("Clicked %s entity at %s", pEntClicked->GetName().c_str(),pVList->m_variant[1].Print().c_str());
GetEntityRoot()->PrintTreeAsText(); //useful for debugging
//GetEntityRoot()->PrintTreeAsText(); //useful for debugging
Entity *pDarken = GetEntityRoot()->GetEntityByName("pop_up_darken");
FadeScreen(pDarken, 0, 0, 400, true);
KillEntity(pDarken, 400);
@ -114,7 +114,7 @@ Entity * CreateQuickTip(Entity *pParentEnt, string tipFileName, bool bRequireMov
//pButtonEntity = CreateOverlayButtonEntity(pBG, "continue", "interface/quicktips/tip_continue.rttex", 178, 184);
pButtonEntity->GetFunction("OnButtonSelected")->sig_function.connect(&QuickTipMenuOnSelect);
SlideScreen(pBG, true);
GetEntityRoot()->PrintTreeAsText(); //useful for debugging
//GetEntityRoot()->PrintTreeAsText(); //useful for debugging
//FadeInEntity(pBG, true, 300);
GetAudioManager()->Play("audio/tip_start.wav");

View file

@ -30,7 +30,7 @@ void ReadTextMenuOnSelect(VariantList *pVList) //0=vec2 point of click, 1=entity
return;
}
GetEntityRoot()->PrintTreeAsText(); //useful for debugging
//GetEntityRoot()->PrintTreeAsText(); //useful for debugging
}