section.begin
   Name = EventMainMenu
   Code : struct.begin
      [*] = ;var elmHnd : Integer = GetIntValueByName('ElementHandle');
      [*] = ;var press : String = GetValueByName('Press');
      [*] = ;var tag : Integer = GetIntValueByName('Tag');
      [*] = ;
      [*] = ;const currentstatename = 'EventMainMenu';
      [*] = ;var elmname, showstate, eventstate : String;
      [*] = ;_misc_GetGUIShowEventStateNames(currentstatename, elmname, showstate, eventstate);
      [*] = ;
      [*] = ;const cTagProfile = 100;
      [*] = ;const cTagCampaign = 101;
      [*] = ;const cTagRandomMap = 102;
      [*] = ;const cTagMultiplayer = 103;
      [*] = ;const cTagSettings = 104;
      [*] = ;const cTagLoadGame = 105;
      [*] = ;const cTagLoadReplay = 106;
      [*] = ;const cTagEditor = 107;
      [*] = ;const cTagModManager = 108;
      [*] = ;const cTagExit = 109;
      [*] = ;const cTagTutorial = 110;
      [*] = ;
      [*] = ;if (tag=cTagProfile) and (GetGUIShiftStateCtrl) then
      [*] = ;tag := cTagMultiplayer;
      [*] = ;
      [*] = ;if (press='c') then
      [*] = ;begin
      [*] = ;   case tag of
      [*] = ;      cTagTutorial : begin
      [*] = ;         gint_campaign_selectedcampaign := -1;
      [*] = ;         gint_campaign_selectedmission := 0;
      [*] = ;         gstring_campaign_exittomenu_campname := 'tutcam';
      [*] = ;         gstring_campaign_exittomenu_missname := 'tutmis1';
      [*] = ;         const cTagCampaign = 101;
      [*] = ;         _gui_SendTagToState('EventMainMenu', cTagCampaign);
      [*] = ;
      [*] = ;         gint_campaign_exittomenu_status := gc_campaign_exittomenu_status_none;
      [*] = ;         gstring_campaign_exittomenu_campname := '';
      [*] = ;         gstring_campaign_exittomenu_missname := '';
      [*] = ;      end;
      [*] = ;      cTagProfile : begin
      [*] = ;         ExecuteState('ShowProfile');
      [*] = ;      end;
      [*] = ;      cTagCampaign : begin
      [*] = ;         _gui_SetGUIElementVisibleByName(elmname+'.col1', False);
      [*] = ;         _gui_SetGUIElementVisibleByName('News.Newspn.news', False);
      [*] = ;         _gui_SetGUIElementVisibleByName('News.Newspn.newstransparentmask', False);
      [*] = ;         gint_gui_newsshowvisible := 1;
      [*] = ;         ExecuteState('ShowCampaign');
      [*] = ;      end;
      [*] = ;      cTagSettings : begin
      [*] = ;         _gui_ShowSettingsDialog;
      [*] = ;      end;
      [*] = ;      cTagLoadGame : begin
      [*] = ;         _gui_SetGUIElementVisibleByName(elmname+'.col1', False);
      [*] = ;         _gui_SetGUIElementVisibleByName('News.Newspn.news', False);
      [*] = ;         _gui_SetGUIElementVisibleByName('News.Newspn.newstransparentmask', False);
      [*] = ;         gint_gui_newsshowvisible := 1;
      [*] = ;         gint_gui_saveload_mode := gc_gui_saveload_mode_load;
      [*] = ;         ExecuteState('ShowLoadGame');
      [*] = ;      end;
      [*] = ;      cTagRandomMap : begin
      [*] = ;         _gui_SetGUIElementVisibleByName(elmname+'.col1', False);
      [*] = ;         _gui_SetGUIElementVisibleByName('News.Newspn.news', False);
      [*] = ;         _gui_SetGUIElementVisibleByName('News.Newspn.newstransparentmask', False);
      [*] = ;         gint_gui_newsshowvisible := 1;
      [*] = ;         //reset map settings start
      [*] = ;         _map_ResetMapSettings(gMap, True, True, False, False, False, False);
      [*] = ;         //reset map settings finish
      [*] = ;         var i : Integer;
      [*] = ;         for i:=0 to gc_MaxPlayerCount-1 do
      [*] = ;         gMap.players[i].color := i;
      [*] = ;         gMap.players[gc_player_mercenaryind].color := gc_MaxColorCount-1;
      [*] = ;         ExecuteState('ShowCustomGame');
      [*] = ;      end;
      [*] = ;      cTagMultiplayer : begin
      [*] = ;         //_gui_ShowConnectStateMessage(gc_ConnectState_OutOfOrder);
      [*] = ;         //reset map settings start
      [*] = ;         gInternetShell.autosearchrealstarttime := 0;
      [*] = ;         gInternetShell.ClearQuickPlay;
      [*] = ;         gInternetShell.rankingslastupdate := 0;
      [*] = ;         _map_ResetMapSettings(gMap, False, True, False, False, False, False);
      [*] = ;         if (gProfileTmp.netemail='') then
      [*] = ;         begin
      [*] = ;            gProfileTmp.netemail := gProfile.netemail;
      [*] = ;            gProfileTmp.netpass := gProfile.netpass;
      [*] = ;            gProfileTmp.netcdkey := gProfile.netcdkey;
      [*] = ;         end;
      [*] = ;         if (gProfileTmp.netcdkey='') then
      [*] = ;         _steam_thirdparty_cdkey(gProfileTmp.netcdkey);
      [*] = ;         ExecuteState('DoConnectServer');
      [*] = ;         _gui_ShowConnectStateMessage(gc_ConnectState_WaitServer);
      [*] = ;         _gui_SetGUIElementVisibleByName(elmname+'.col1', False); // leave it at en.d
      [*] = ;         _gui_SetGUIElementVisibleByName('News.Newspn.news', False);
      [*] = ;         _gui_SetGUIElementVisibleByName('News.Newspn.newstransparentmask', False);
      [*] = ;         gint_gui_newsshowvisible := 1;
      [*] = ;
      [*] = ;         if gstring_checksum='' then
      [*] = ;         _init_CalcCheckSum;
      [*] = ;      end;
      [*] = ;      cTagLoadReplay : begin
      [*] = ;         _gui_SetGUIElementVisibleByName(elmname+'.col1', False);
      [*] = ;         _gui_SetGUIElementVisibleByName('News.Newspn.news', False);
      [*] = ;         _gui_SetGUIElementVisibleByName('News.Newspn.newstransparentmask', False);
      [*] = ;         gint_gui_newsshowvisible := 1;
      [*] = ;         gint_gui_saveload_mode := gc_gui_saveload_mode_loadreplay;
      [*] = ;         gstring_gui_saveload_name := '';
      [*] = ;         gint_gui_saveload_ind := -1;
      [*] = ;         gint_gui_saveload_enum := -1;
      [*] = ;         ExecuteState('ShowLoadGame');
      [*] = ;      end;
      [*] = ;      gc_gui_event_tagShow : ExecuteState(showstate);
      [*] = ;      cTagEditor : begin
      [*] = ;         var scenario : TScenario;
      [*] = ;         gScenario := scenario;
      [*] = ;         gScenarioTmp := scenario;
      [*] = ;         gInterface.gamemode := gc_gamemode_editor;
      [*] = ;         SetClipCursor(gProfile.bclipmouse and IsEngine and (gInterface.gamemode<>gc_gamemode_mainmenu));
      [*] = ;         UnregisterGUIAllShortcuts;
      [*] = ;         GUIExecuteState('RegisterShortcuts');
      [*] = ;         SetGUIMiniMapVisible(True);
      [*] = ;         var minimapHnd : Integer = GetGUIElementIndexByNameParent('minimap', _gui_GetTop);
      [*] = ;         if (minimapHnd<>0) then
      [*] = ;         SetGUIElementVisible(minimapHnd, True);
      [*] = ;         var camera : Integer = GetGUIElementTopIndexByName(gc_gui_element_camera);
      [*] = ;         SetGUIElementVisible(camera, True);
      [*] = ;         //GUIMiniMapUpdate;
      [*] = ;         _gui_SetGUIElementVisibleByName(elmname, False);
      [*] = ;         if (GetCountOfPlayers>0) then
      [*] = ;         begin
      [*] = ;            gbool_editor_fogofwar := False;
      [*] = ;            var plInd : Integer = GetPlayerIndexByHandle(GetPlayerHandleInterfaceIO);
      [*] = ;            _player_UpdateFOW(plInd);
      [*] = ;         end;
      [*] = ;         SetProgressingPauseMode(False);
      [*] = ;         ExecuteState('ShowPause');
      [*] = ;
      [*] = ;         var i : Integer;
      [*] = ;         for i:=0 to gc_MaxPlayerCount-1 do
      [*] = ;         begin
      [*] = ;            gPlayer[i].playeradviser.adviser.bavailable := (gProfileUserStruct.adviserdefault.bavailable);
      [*] = ;            //gPlayer[i].playeradviser.adviser.benable := False;
      [*] = ;            gPlayer[i].playeradviser.adviser.bvisible := False;
      [*] = ;         end;
      [*] = ;         gbool_gui_updateadviser := True;
      [*] = ;         gbool_gui_updateadviseradvice := True;
      [*] = ;
      [*] = ;         var elm : Integer = GetGUIElementIndexByNameParent('News', _gui_GetTop);
      [*] = ;         if (elm<>0) and (GetGUIElementVisible(elm)) then
      [*] = ;         SetGUIElementVisible(elm, False);
      [*] = ;      end;
      [*] = ;      cTagModManager : begin
      [*] = ;         OpenURL('http://steamcommunity.com/app/333420/workshop/');
      [*] = ;      end;
      [*] = ;      gc_gui_event_tagHide : begin
      [*] = ;         // Escape handler for debug porposes
      [*] = ;         if (gInterface.gamemode=gc_gamemode_mainmenu) then
      [*] = ;         begin
      [*] = ;            gInterface.gamemode := gc_gamemode_editor;
      [*] = ;            SetClipCursor(gProfile.bclipmouse and IsEngine and (gInterface.gamemode<>gc_gamemode_mainmenu));
      [*] = ;            UnregisterGUIAllShortcuts;
      [*] = ;            GUIExecuteState('RegisterShortcuts');
      [*] = ;            SetGUIMiniMapVisible(True);
      [*] = ;            var minimapHnd : Integer = GetGUIElementIndexByNameParent('minimap', _gui_GetTop);
      [*] = ;            if (minimapHnd<>0) then
      [*] = ;            SetGUIElementVisible(minimapHnd, True);
      [*] = ;         end;
      [*] = ;         _gui_SetGUIElementVisibleByName(elmname, False);
      [*] = ;      end;
      [*] = ;      cTagExit : CloseQuery;
      [*] = ;   end;
      [*] = ;end;
   struct.end
section.end

