Allow leaving failed-start screens; record Workshop 0.0.122
continuous-integration/drone/push Build is passing
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -11,7 +11,7 @@ def cpp(s):
|
||||
s=s.replace('current.Phase()', 'current->Phase()')
|
||||
s=s.replace('ERR_GameMode mode,','ERR_GameMode* mode,')
|
||||
s=s.replace('ERR_GameMode mode)', 'ERR_GameMode* mode)')
|
||||
for name in ['System','ERR_GameMode','ERR_Phase','ERR_ObjectiveText','ERR_MissionRules']:s=s.replace(name+'.',name+'::')
|
||||
for name in ['System','ERR_GameMode','ERR_Phase','ERR_ObjectiveText','ERR_MissionRules','ERR_PreparationFailureMenu']:s=s.replace(name+'.',name+'::')
|
||||
s=s.replace('TextWidget.Cast(','CastText(').replace('Widget widget)', 'Widget* widget)').replace('widget.', 'widget->')
|
||||
for name in ['mode','m_wLoadingPlaceholder','m_ERRPreparationSpinner','m_ERRPreparationRoot','m_ERRPreparationTitle','m_ERRPreparationDescription']:
|
||||
s=s.replace(name+'.',name+'->')
|
||||
@@ -27,6 +27,7 @@ namespace System{bool console=false;bool IsConsoleApp(){return console;}}
|
||||
namespace ERR_Phase{enum{PREPARING,PRISON,RADIO_SEARCH,RADIO_DEFENCE,EXTRACTION,VICTORY,DEFEAT};}
|
||||
namespace ERR_MissionRules{bool Terminal(int p){return p==ERR_Phase::VICTORY||p==ERR_Phase::DEFEAT;}}
|
||||
struct ERR_GameMode{static ERR_GameMode* current;int phase=ERR_Phase::PREPARING;string error;static ERR_GameMode* Get(){return current;}int Phase(){return phase;}bool Active(){return phase>=ERR_Phase::PRISON&&phase<=ERR_Phase::EXTRACTION;}string PreparationError(){return error;}};ERR_GameMode* ERR_GameMode::current=nullptr;
|
||||
namespace ERR_PreparationFailureMenu{bool shown=false;bool Show(ERR_GameMode*){return shown;}bool Visible(ERR_GameMode*){return shown;}};
|
||||
namespace ERR_ObjectiveText{string Description(ERR_GameMode* mode,bool){return mode->error.empty()?"Preparing sites":"Mission failed; ask an administrator to correct and restart";}}
|
||||
struct Widget{Widget* parent=nullptr;bool visible=true,removed=false,textWidget=false;string text;int textWrites=0,visibilityWrites=0;float width=900,height=170;std::map<string,Widget*> children;
|
||||
void GetScreenSize(float& w,float& h){w=width;h=height;}Widget* GetParent(){return parent;}void RemoveFromHierarchy(){removed=true;parent=nullptr;}void SetVisible(bool value){visible=value;visibilityWrites++;}bool IsVisible(){return visible;}
|
||||
@@ -40,8 +41,9 @@ struct Probe:Native{
|
||||
bool m_ERRKeepSpawnSceneLoading=false,m_ERRPreparationSpinnerHidden=false,m_ERRPreparationSpinnerWasVisible=false;string m_ERRPreparationLastTitle,m_ERRPreparationLastDescription;
|
||||
'''+methods+r'''
|
||||
};
|
||||
struct Fixture{ERR_GameMode mode;Widget parent,spinner;Probe p;Fixture(){game.workspace={};System::console=false;ERR_GameMode::current=&mode;p.m_pGameMode=&mode;p.m_wLoadingPlaceholder=&parent;parent.children["Spinner"]=&spinner;spinner.parent=&parent;}};
|
||||
struct Fixture{ERR_GameMode mode;Widget parent,spinner;Probe p;Fixture(){game.workspace={};System::console=false;ERR_PreparationFailureMenu::shown=false;ERR_GameMode::current=&mode;p.m_pGameMode=&mode;p.m_wLoadingPlaceholder=&parent;parent.children["Spinner"]=&spinner;spinner.parent=&parent;}};
|
||||
int main(){
|
||||
{Fixture f;f.mode.error="bad";ERR_PreparationFailureMenu::shown=true;f.p.UpdateLoadingPlaceholder(.1f);assert(!f.parent.visible&&f.p.ERR_ProbePreparationVisible(&f.mode,true));}
|
||||
{Fixture f;f.mode.phase=ERR_Phase::PRISON;f.p.ERR_ShowSpawnSceneLoading();auto root=f.p.m_ERRPreparationRoot;f.p.ERR_KeepSpawnSceneLoading(true);f.p.DestroyLoadingPlaceholder();assert(!root->removed&&!f.parent.removed&&f.p.destroys==0);f.p.ERR_KeepSpawnSceneLoading(false);f.p.DestroyLoadingPlaceholder();assert(root->removed&&f.p.destroys==1);f.p.ERR_ShowSpawnSceneLoading();assert(f.p.m_wLoadingPlaceholder&&f.p.ERR_ProbePreparationVisible(&f.mode,false));}
|
||||
{Fixture f;f.p.UpdateLoadingPlaceholder(.1f);assert(f.p.nativeUpdates==1&&game.workspace.creates==1&&f.p.ERR_ProbePreparationVisible(&f.mode,false));
|
||||
Widget* root=f.p.m_ERRPreparationRoot;auto title=f.p.m_ERRPreparationTitle;auto description=f.p.m_ERRPreparationDescription;
|
||||
|
||||
Reference in New Issue
Block a user