MSS

Добавлен , опубликован

Mode Selection System

Система выбора режима игры через диалоговое окно.
Описание:
Вы нажимаете на кнопку мод изменяется, при нажатии на кнопку OK все вібраные вами моды применяются(P.s. сами моды я не делал, но их добавить легко) .
Так же есть встроенная система определения хоста карты.
Импорт: просто скопируйте триггер Diabloge к себе в карту.
Если возникли какие то вопросы обращайтесь ко мне в лс.
vJass
library ModSelection initializer Init

 globals
  private dialog           Dialog                     = DialogCreate()
  private button           OkButton
  private string   array   GameMode
  private string   array   ComplexityGame
  private button   array   Button
  private integer  array   ButtonIndex
  private integer          MaxButton                  = 2
  private integer  array   MaxModeButton
  private player           Host
 endglobals

  
  private function EditDialoge takes nothing returns nothing
     call DialogClear(Dialog)
     call DialogSetMessage(Dialog,"|c00FF0303Game Options|r")
    set Button               [1] = DialogAddButton(Dialog,"|c00FEBA0EGame Mode: |r"  +  GameMode      [ButtonIndex[1]],0)
    set Button               [2] = DialogAddButton(Dialog,"|c00FEBA0EComplexity: |r" +  ComplexityGame[ButtonIndex[2]],0)
    set OkButton                 = DialogAddButton(Dialog,"|c0020C000OK!|r"                                           ,0)
     call DialogDisplay(Host, Dialog, true)
  endfunction
  
  private function HostClick takes nothing returns nothing
   local integer i = 1
      loop
       if GetClickedButton() == Button[i] then
    set ButtonIndex[i] = ButtonIndex[i] + 1
    if ButtonIndex[i] > MaxModeButton[i] then
     set ButtonIndex[i] = 1
    endif
     call EditDialoge()
       endif
      exitwhen i == MaxButton
    set i = i + 1
      endloop
       if  GetClickedButton() == OkButton then
       if (IsPlayerInForce(GetLocalPlayer(), bj_FORCE_ALL_PLAYERS)) then
        call DisplayTextToPlayer(GetLocalPlayer(), 0, 0, "|c00FF0303Game Options:|r")
        call DisplayTextToPlayer(GetLocalPlayer(), 0, 0, "|c00FFFC01------------------------------------|r")
        call DisplayTextToPlayer(GetLocalPlayer(), 0, 0, "|c00FEBA0EGame Mode: |r" + GameMode[ButtonIndex[1]])
        call DisplayTextToPlayer(GetLocalPlayer(), 0, 0, "|c00FEBA0EComplexity Game: |r" + ComplexityGame[ButtonIndex[1]])
       endif
       endif
  endfunction

  private function GetHost takes nothing returns nothing
   local gamecache g = InitGameCache("Map.w3v")
     call StoreInteger ( g, "Map", "Host", GetPlayerId(GetLocalPlayer ())+1)
     call TriggerSyncStart ()
     call SyncStoredInteger ( g, "Map", "Host" )
     call TriggerSyncReady ()
    set Host = Player( GetStoredInteger ( g, "Map", "Host" )-1)
     call FlushGameCache( g )
    set g = null
  endfunction
  
  private function CreateDialog takes nothing returns nothing
     call GetHost()
   
     call DialogSetMessage(Dialog,"|c00FF0303Game Options|r")
   
    set GameMode             [1] = "|c00FFFFFFAll Pick|r"
    set GameMode             [2] = "|c00FFFFFFAll Random|r"
    set GameMode             [3] = "|c00FFFFFFSingle Draft|r"
    set ComplexityGame       [1] = "|c00FFFFFFEasy|r"
    set ComplexityGame       [2] = "|c00FFFFFFNormal|r"
    set ComplexityGame       [3] = "|c00FFFFFFHard|r"
    
    set MaxModeButton[1] = 2
    set MaxModeButton[2] = 3
    
   local integer i = 1
      loop
    set ButtonIndex[i] = 1
      exitwhen i == MaxButton
    set i = i + 1
      endloop
    set Button               [1] = DialogAddButton(Dialog,"|c00FEBA0EGame Mode: |r"  +  GameMode      [1],0)
    set Button               [2] = DialogAddButton(Dialog,"|c00FEBA0EComplexity: |r" +  ComplexityGame[1],0)
    set OkButton                 = DialogAddButton(Dialog,"|c0020C000OK!|r"                              ,0)
    
     call DialogDisplay(Host, Dialog, true)
    
  endfunction
  
  private function Init takes nothing returns nothing
   local trigger CreateD = CreateTrigger()
     call TriggerRegisterTimerEvent(CreateD,0., false)
     call TriggerAddAction(CreateD, function CreateDialog)
    set CreateD = null
   local trigger Click = CreateTrigger()
     call TriggerRegisterDialogEvent(Click,Dialog)
     call TriggerAddAction(Click, function HostClick)
    set Click = null
  endfunction
    
endlibrary

Скриншоты