Skip to content

Instantly share code, notes, and snippets.

@ChugunovRoman
Created February 10, 2021 08:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ChugunovRoman/4e2c19afbc7810dc7e1dc721e263fe88 to your computer and use it in GitHub Desktop.
Save ChugunovRoman/4e2c19afbc7810dc7e1dc721e263fe88 to your computer and use it in GitHub Desktop.
ui_addon_azazel_faction_chooser.script
local inAlive = alife()
azazel_death = false
addon_azazel_menu = {}
class "addonAzazelFactionChooser"(CUIScriptWnd)
function addonAzazelFactionChooser:__init(mainmenuReference)
super()
self.mainmenuReference = mainmenuReference
if not addon_azazel_menu.factionsPool then
addon_azazel_menu.factionsPool = {
["stalker"] = false,
["bandit"] = false,
["csky"] = false,
["dolg"] = false,
["freedom"] = false,
["killer"] = false,
["army"] = false,
["ecolog"] = false,
["monolith"] = false,
["isg"] = false,
["darkstalker"] = false,
["renegate"] = false,
["mstitel"] = false,
["slizni"] = false,
["velhan"] = false,
["fantom"] = false,
["osoznanie"] = false,
["ansf"] = false,
["alfa"] = false,
["veter"] = false,
["adinkvizicia"] = false,
["zakat"] = false,
["voenstal"] = false,
["ryskuspecnaz"] = false,
["sby"] = false,
["terrorust"] = false,
["posleduden"] = false,
["greh"] = false,
["mirotvorec"] = false
}
end
self.factionsPool = addon_azazel_menu.factionsPool
self.factionsList = {
"stalker",
"bandit",
"csky",
"dolg",
"freedom",
"killer",
"army",
"ecolog",
"monolith",
"osoznanie",
"isg",
"darkstalker",
"renegate",
"mstitel",
"slizni",
"velhan",
"fantom",
"ansf",
"alfa",
"veter",
"adinkvizicia",
"zakat",
"voenstal",
"ryskuspecnaz",
"sby",
"terrorust",
"posleduden",
"greh",
"mirotvorec"
}
self.checkBoxesList = {"doNotPlayAnimation", "findNearest"}
self:InitControls()
if inAlive and self.mainmenuReference then
self.mainmenuReference:Show(false)
end
self:InitCallBacks()
end
function addonAzazelFactionChooser:__finalize()
end
function addonAzazelFactionChooser:InitControls()
self:SetWndRect(Frect():set(0, 0, 1024, 768))
local xml = CScriptXmlInit()
xml:ParseFile("ui_addon_azazel_faction_chooser.xml")
self.table = {
"background"
}
for i = 1, #self.table do
xml:InitStatic(self.table[i], self)
end
self.btn_ok = xml:Init3tButton("btn_ok", self)
self:Register(self.btn_ok, "btn_ok")
local columnLimit = 5
local posX = 1
local posY = 150
for i = 1, #self.factionsList do
self["btn_" .. self.factionsList[i]] = xml:Init3tButton("faction_" .. self.factionsList[i], self)
self["btn_" .. self.factionsList[i]]:SetWndSize(vector2():set(110, 70))
self["btn_" .. self.factionsList[i]]:SetWndPos(vector2():set((120 * posX) + 80, posY))
self:Register(self["btn_" .. self.factionsList[i]], "btn_" .. self.factionsList[i])
self["icon_" .. self.factionsList[i]] =
xml:InitStatic(strformat("faction_%s:icon_%s", self.factionsList[i], self.factionsList[i]), self)
self["icon_" .. self.factionsList[i]]:InitTexture(getSenderSmsIcon(self.factionsList[i]))
self["icon_" .. self.factionsList[i]]:SetStretchTexture(true)
self["icon_" .. self.factionsList[i]]:SetWndSize(vector2():set(110, 70))
self["icon_" .. self.factionsList[i]]:SetWndPos(vector2():set((120 * posX) + 80, posY))
self["icon_" .. self.factionsList[i]]:SetTextureColor(GetARGB(255, 70, 70, 70))
posX = posX + 1
if (i % columnLimit) == 0 then
posY = posY + 80
posX = 1
end
end
self.btn_ok:Show(false)
end
function addonAzazelFactionChooser:InitCallBacks()
self:AddCallback("btn_ok", ui_events.BUTTON_CLICKED, self["Ok"], self)
for i = 1, #self.factionsList do
self:AddCallback(
"btn_" .. self.factionsList[i],
ui_events.BUTTON_CLICKED,
self["OnFaction_" .. self.factionsList[i]],
self
)
end
end
function addonAzazelFactionChooser:Update()
CUIScriptWnd.Update(self)
end
function addonAzazelFactionChooser:OnFaction_stalker()
self:OnFactionSelect("stalker")
end
function addonAzazelFactionChooser:OnFaction_bandit()
self:OnFactionSelect("bandit")
end
function addonAzazelFactionChooser:OnFaction_csky()
self:OnFactionSelect("csky")
end
function addonAzazelFactionChooser:OnFaction_dolg()
self:OnFactionSelect("dolg")
end
function addonAzazelFactionChooser:OnFaction_freedom()
self:OnFactionSelect("freedom")
end
function addonAzazelFactionChooser:OnFaction_killer()
self:OnFactionSelect("killer")
end
function addonAzazelFactionChooser:OnFaction_army()
self:OnFactionSelect("army")
end
function addonAzazelFactionChooser:OnFaction_ecolog()
self:OnFactionSelect("ecolog")
end
function addonAzazelFactionChooser:OnFaction_monolith()
self:OnFactionSelect("monolith")
end
function addonAzazelFactionChooser:OnFaction_osoznanie()
self:OnFactionSelect("osoznanie")
end
function addonAzazelFactionChooser:OnFaction_isg()
self:OnFactionSelect("isg")
end
function addonAzazelFactionChooser:OnFaction_darkstalker()
self:OnFactionSelect("darkstalker")
end
function addonAzazelFactionChooser:OnFaction_renegate()
self:OnFactionSelect("renegate")
end
function addonAzazelFactionChooser:OnFaction_mstitel()
self:OnFactionSelect("mstitel")
end
function addonAzazelFactionChooser:OnFaction_slizni()
self:OnFactionSelect("slizni")
end
function addonAzazelFactionChooser:OnFaction_velhan()
self:OnFactionSelect("velhan")
end
function addonAzazelFactionChooser:OnFaction_fantom()
self:OnFactionSelect("fantom")
end
function addonAzazelFactionChooser:OnFaction_veter()
self:OnFactionSelect("veter")
end
function addonAzazelFactionChooser:OnFaction_osoznanie()
self:OnFactionSelect("osoznanie")
end
function addonAzazelFactionChooser:OnFaction_ansf()
self:OnFactionSelect("ansf")
end
function addonAzazelFactionChooser:OnFaction_alfa()
self:OnFactionSelect("alfa")
end
function addonAzazelFactionChooser:OnFaction_adinkvizicia()
self:OnFactionSelect("adinkvizicia")
end
function addonAzazelFactionChooser:OnFaction_zakat()
self:OnFactionSelect("zakat")
end
function addonAzazelFactionChooser:OnFaction_voenstal()
self:OnFactionSelect("voenstal")
end
function addonAzazelFactionChooser:OnFaction_ryskuspecnaz()
self:OnFactionSelect("ryskuspecnaz")
end
function addonAzazelFactionChooser:OnFaction_sby()
self:OnFactionSelect("sby")
end
function addonAzazelFactionChooser:OnFaction_terrorust()
self:OnFactionSelect("terrorust")
end
function addonAzazelFactionChooser:OnFaction_posleduden()
self:OnFactionSelect("posleduden")
end
function addonAzazelFactionChooser:OnFaction_mirotvorec()
self:OnFactionSelect("mirotvorec")
end
function addonAzazelFactionChooser:OnFaction_greh()
self:OnFactionSelect("greh")
end
function addonAzazelFactionChooser:OnFaction_random()
self:OnFactionSelect("random")
end
function addonAzazelFactionChooser:OnFactionSelect(faction)
self.factionsPool[faction] = not self.factionsPool[faction]
printf(self.factionsPool[faction])
if self.factionsPool[faction] then
self["icon_" .. faction]:SetTextureColor(GetARGB(255, 255, 255, 255))
else
self["icon_" .. faction]:SetTextureColor(GetARGB(255, 70, 70, 70))
end
self:UpdateOkVisibility()
end
function addonAzazelFactionChooser:SwitchCheckbox(checkboxName)
if (addon_azazel_menu[checkboxName]) then
self["checkbox_" .. checkboxName .. "_unchecked"]:Show(true)
self["checkbox_" .. checkboxName .. "_checked"]:Show(false)
addon_azazel_menu[checkboxName] = false
else
self["checkbox_" .. checkboxName .. "_unchecked"]:Show(false)
self["checkbox_" .. checkboxName .. "_checked"]:Show(true)
addon_azazel_menu[checkboxName] = true
end
end
function addonAzazelFactionChooser:UpdateOkVisibility()
for i = 1, #self.factionsList do
if self.factionsPool[self.factionsList[i]] then
self.btn_ok:Show(true)
return
end
end
self.btn_ok:Show(false)
end
function addonAzazelFactionChooser:Ok()
if not inAlive then
self:HideDialog()
self:Show(false)
return
end
if (azazel_mode.addonStep2(false)) then
self:HideDialog()
self:Show(false)
get_console():execute("main_menu off")
--device():pause(false)
end
end
<addonAzazelFactionChooser>
<background>
<auto_static x="0" y="0" width="1024" height="768" stretch="1">
<texture>ui\ui_addon_azazel_faction_chooser_backgroundColor</texture>
</auto_static>
</background>
<faction_freedom x="70" y="310" width="110" height="70">
<icon_freedom x="0" y="0" width="110" height="70" stretch="1" />
</faction_freedom>
<faction_dolg x="70" y="370" width="110" height="70">
<icon_dolg x="0" y="0" width="110" height="70" stretch="1" />
</faction_dolg>
<faction_killer x="70" y="432" width="110" height="70">
<icon_killer x="0" y="0" width="110" height="70" stretch="1" />
</faction_killer>
<faction_stalker x="70" y="490" width="110" height="70">
<icon_stalker x="0" y="0" width="110" height="70" stretch="1" />
</faction_stalker>
<faction_bandit x="70" y="550" width="110" height="70">
<icon_bandit x="0" y="0" width="110" height="70" stretch="1" />
</faction_bandit>
<faction_csky x="200" y="310" width="110" height="70">
<icon_csky x="0" y="0" width="110" height="70" stretch="1" />
</faction_csky>
<faction_monolith x="200" y="370" width="110" height="70">
<icon_monolith x="0" y="0" width="110" height="70" stretch="1" />
</faction_monolith>
<faction_army x="200" y="432" width="110" height="70">
<icon_army x="0" y="0" width="110" height="70" stretch="1" />
</faction_army>
<faction_ecolog x="200" y="490" width="110" height="70">
<icon_ecolog x="0" y="0" width="110" height="70" stretch="1" />
</faction_ecolog>
<faction_darkstalker x="200" y="550" width="110" height="70">
<icon_darkstalker x="0" y="0" width="110" height="70" stretch="1" />
</faction_darkstalker>
<faction_isg x="330" y="310" width="110" height="70">
<icon_isg x="0" y="0" width="110" height="70" stretch="1" />
</faction_isg>
<faction_renegate x="330" y="370" width="110" height="70">
<icon_renegate x="0" y="0" width="110" height="70" stretch="1" />
</faction_renegate>
<faction_mstitel x="330" y="432" width="110" height="70">
<icon_mstitel x="0" y="0" width="110" height="70" stretch="1" />
</faction_mstitel>
<faction_fantom x="330" y="490" width="110" height="70">
<icon_fantom x="0" y="0" width="110" height="70" stretch="1" />
</faction_fantom>
<faction_velhan x="330" y="550" width="110" height="70">
<icon_velhan x="0" y="0" width="110" height="70" stretch="1" />
</faction_velhan>
<faction_osoznanie x="460" y="310" width="110" height="70">
<icon_osoznanie x="0" y="0" width="110" height="70" stretch="1" />
</faction_osoznanie>
<faction_alfa x="460" y="370" width="110" height="70">
<icon_alfa x="0" y="0" width="110" height="70" stretch="1" />
</faction_alfa>
<faction_mirotvorec x="460" y="432" width="110" height="70">
<icon_mirotvorec x="0" y="0" width="110" height="70" stretch="1" />
</faction_mirotvorec>
<faction_slizni x="460" y="490" width="110" height="70">
<icon_slizni x="0" y="0" width="110" height="70" stretch="1" />
</faction_slizni>
<faction_ryskuspecnaz x="460" y="550" width="110" height="70">
<icon_ryskuspecnaz x="0" y="0" width="110" height="70" stretch="1" />
</faction_ryskuspecnaz>
<faction_voenstal x="590" y="310" width="110" height="70">
<icon_voenstal x="0" y="0" width="110" height="70" stretch="1" />
</faction_voenstal>
<faction_posleduden x="590" y="370" width="110" height="70">
<icon_posleduden x="0" y="0" width="110" height="70" stretch="1" />
</faction_posleduden>
<faction_terrorust x="590" y="432" width="110" height="70">
<icon_terrorust x="0" y="0" width="110" height="70" stretch="1" />
</faction_terrorust>
<faction_sby x="590" y="490" width="110" height="70">
<icon_sby x="0" y="0" width="110" height="70" stretch="1" />
</faction_sby>
<faction_veter x="590" y="550" width="110" height="70">
<icon_veter x="0" y="0" width="110" height="70" stretch="1" />
</faction_veter>
<faction_ansf x="720" y="310" width="110" height="70">
<icon_ansf x="0" y="0" width="110" height="70" stretch="1" />
</faction_ansf>
<faction_zakat x="720" y="370" width="110" height="70">
<icon_zakat x="0" y="0" width="110" height="70" stretch="1" />
</faction_zakat>
<faction_adinkvizicia x="720" y="432" width="110" height="70">
<icon_adinkvizicia x="0" y="0" width="110" height="70" stretch="1" />
</faction_adinkvizicia>
<faction_greh x="720" y="490" width="110" height="70">
<icon_greh x="0" y="0" width="110" height="70" stretch="1" />
</faction_greh>
<btn_ok x="10" y="10" width="21" height="15" stretch="1">
<auto_static x="0" y="0" width="21" height="15" stretch="1">
<texture>btn_ok</texture>
</auto_static>
</btn_ok>
<label_dead x="444" y="150">
<text r="190" g="190" b="190" font="graffiti50" align="c" vert_align="c">st_addon_azazel_faction_chooser_label_chooseFaction</text>
</label_dead>
<label_choseFaction x="512" y="475">
<text r="190" g="190" b="190" font="graffiti32" align="c" vert_align="c">st_addon_azazel_faction_chooser_label_dead</text>
</label_choseFaction>
<label_doNotPlayAnimation x="646" y="550">
<text r="190" g="190" b="190" font="graffiti22" align="l" vert_align="c">st_addon_azazel_faction_chooser_label_doNotPlayAnimation</text>
</label_doNotPlayAnimation>
<checkbox_doNotPlayAnimation_checked x="625" y="543" width="32" height="32">
<auto_static width="20" height="20" stretch="1">
<texture x="32" y="0" width="32" height="32">ui\ui_addon_azazel_faction_chooser_icons</texture>
</auto_static>
</checkbox_doNotPlayAnimation_checked>
<checkbox_doNotPlayAnimation_unchecked x="625" y="543" width="32" height="32">
<auto_static width="20" height="20" stretch="1">
<texture x="0" y="0" width="32" height="32">ui\ui_addon_azazel_faction_chooser_icons</texture>
</auto_static>
</checkbox_doNotPlayAnimation_unchecked>
<label_findNearest x="646" y="590">
<text r="190" g="190" b="190" font="graffiti22" align="l" vert_align="c">st_addon_azazel_faction_chooser_label_findNearest</text>
</label_findNearest>
<checkbox_findNearest_checked x="625" y="583" width="32" height="32">
<auto_static width="20" height="20" stretch="1">
<texture x="32" y="0" width="32" height="32">ui\ui_addon_azazel_faction_chooser_icons</texture>
</auto_static>
</checkbox_findNearest_checked>
<checkbox_findNearest_unchecked x="625" y="583" width="32" height="32">
<auto_static width="20" height="20" stretch="1">
<texture x="0" y="0" width="32" height="32">ui\ui_addon_azazel_faction_chooser_icons</texture>
</auto_static>
</checkbox_findNearest_unchecked>
</addonAzazelFactionChooser>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment