128 lines
3.4 KiB
C++
128 lines
3.4 KiB
C++
#include "SquirrelStage.h"
|
||
|
||
#include "SquirrelClassEx.h"
|
||
extern SquirrelClassEx* TObject;
|
||
extern Cursor* Mouse_Object;
|
||
|
||
extern std::map<std::uint64_t, int>UI_HOVER_ZORDER;
|
||
extern std::map<std::uint64_t, UiFrameWork*>UI_HOVER_OBJECT;
|
||
|
||
|
||
|
||
void SquirrelStage::OnEvent(Event* evt) {
|
||
if (evt->IsType<KeyEvent>())
|
||
{
|
||
if (evt->IsType<KeyDownEvent>())
|
||
{
|
||
KeyCode key = dynamic_cast<KeyDownEvent*>(evt)->code;
|
||
SquirrelClassEx::RunUpdateScript("KeyDownEventCallBack", (int)key);
|
||
}
|
||
else if (evt->IsType<KeyUpEvent>())
|
||
{
|
||
KeyCode key = dynamic_cast<KeyUpEvent*>(evt)->code;
|
||
SquirrelClassEx::RunUpdateScript("KeyUpEventCallBack", (int)key);
|
||
}
|
||
else if (evt->IsType<KeyCharEvent>())
|
||
{
|
||
char ch = dynamic_cast<KeyCharEvent*>(evt)->value;
|
||
SquirrelClassEx::RunUpdateScript("KeyCharEventCallBack", (int)ch);
|
||
}
|
||
else if (evt->IsType<IMEInputEvent>())
|
||
{
|
||
const auto& str = dynamic_cast<IMEInputEvent*>(evt)->value;
|
||
const auto utf8_str = strings::WideToUTF8(strings::NarrowToWide(str));
|
||
SquirrelClassEx::RunUpdateScript("KeyIMEInputEventCallBack", utf8_str.c_str());
|
||
}
|
||
}
|
||
}
|
||
|
||
void SquirrelStage::InitKeyInPut()
|
||
{
|
||
AddListener<KeyDownEvent>(Closure(this, &SquirrelStage::OnEvent));
|
||
AddListener<KeyUpEvent>(Closure(this, &SquirrelStage::OnEvent));
|
||
AddListener<KeyCharEvent>(Closure(this, &SquirrelStage::OnEvent));
|
||
AddListener<IMEInputEvent>(Closure(this, &SquirrelStage::OnEvent));
|
||
}
|
||
|
||
void SquirrelStage::PushBaseUi()
|
||
{
|
||
//幹秀報炎UI夕蚊
|
||
LayerActorPtr MouseUiLayer = new LayerActor();
|
||
MouseUiLayer->SetName("Scene_Mouse_UI_Layer");
|
||
//譜崔報炎夕蚊蚊雫恷互
|
||
MouseUiLayer->SetZOrder(100000);
|
||
SquirrelClassEx::PushLayerActorPtrToMap(MouseUiLayer);
|
||
this->AddChild(MouseUiLayer);
|
||
|
||
//幹秀潮範夕蚊
|
||
LayerActorPtr DefaultLayer = new LayerActor();
|
||
DefaultLayer->SetName(this->GetName() + "_Default_Layer");
|
||
SquirrelClassEx::PushLayerActorPtrToMap(DefaultLayer);
|
||
this->AddChild(DefaultLayer);
|
||
}
|
||
|
||
void SquirrelStage::OnEnter()
|
||
{
|
||
//繍報炎斤<E7828E>貫幻魁尚卞茅
|
||
Mouse_Object->RemoveFromParent();
|
||
|
||
ActorPtr MouseUiLayer = this->GetChild("Scene_Mouse_UI_Layer");
|
||
|
||
//繍報炎斤<E7828E>譜崔葎輝念魁尚徨斤<E5BEA8>
|
||
MouseUiLayer->AddChild(Mouse_Object);
|
||
|
||
//魁尚序秘
|
||
if(this->GetName().find("GameMap") == std::string::npos)TObject->RunSceneScript(this->GetName() + "_Enter", this);
|
||
//畠蕉序秘
|
||
TObject->RunSceneScript("Game_Enter", this);
|
||
}
|
||
|
||
void SquirrelStage::OnExit()
|
||
{
|
||
//賠腎UI窃Map
|
||
UI_HOVER_ZORDER.clear();
|
||
UI_HOVER_OBJECT.clear();
|
||
|
||
//繍報炎斤<E7828E>貫幻魁尚卞茅
|
||
Mouse_Object->RemoveFromParent();
|
||
//魁尚曜竃
|
||
if (this->GetName().find("GameMap") == std::string::npos)TObject->RunSceneScript(this->GetName() + "_Exit", this);
|
||
//畠蕉曜竃
|
||
TObject->RunSceneScript("Game_Exit", this);
|
||
}
|
||
|
||
|
||
void SquirrelStage::OnUpdate(Duration dt)
|
||
{
|
||
static float TimeFlag = 0.0;
|
||
|
||
TimeFlag += dt.GetSeconds();
|
||
|
||
TObject->RunSceneScript("Game_Proc", this, dt.GetSeconds());
|
||
|
||
if (TimeFlag >= 0.00694) {
|
||
//魁尚Proc
|
||
if (this->GetName().find("GameMap") == std::string::npos)TObject->RunSceneScript(this->GetName() + "_Proc", this, TimeFlag);
|
||
|
||
|
||
if (Director::GetInstance().GetCurrentStage()->GetHashName() == this->GetHashName() && this->GetName().find("LoadingGame") == std::string::npos) {
|
||
//畠蕉Proc
|
||
TObject->RunSceneScript("Game_Proc_144", this, TimeFlag);
|
||
//登僅頁倦俶勣嶷墮
|
||
if (FILE* file = fopen("Yosin_Game_Reloading.Sign", "r")) {
|
||
SquirrelClassEx::ReloadingScript();
|
||
//OnExit();
|
||
//OnEnter();
|
||
fclose(file);
|
||
remove("Yosin_Game_Reloading.Sign");
|
||
}
|
||
}
|
||
|
||
TimeFlag = 0.0;
|
||
}
|
||
|
||
}
|
||
|
||
|
||
|