Deleted32045420User Posted February 19, 2016 Share Posted February 19, 2016 (edited) I am trying to create Commander's choice and the actual code part should be easy enough, the main problem is the UI isnt responding to my tries to override it. Class UIArmory_Promotion_CommandersChoice extends UIArmory_Promotion; var bool b_UseCC; var UIMechaListItem ccMechaItem; var XComGameState_Unit Unit; simulated function InitPromotion(StateObjectReference UnitRef, optional bool bInstantTransition) { super.InitPromotion(UnitRef, bInstantTransition); Unit=XComGameState_Unit(`XCOMHISTORY.GetGameStateForObjectID(UnitRef.ObjectID)); `log("CC Activated!"); //if(Unit.GetRank()==1 &&b_UseCC) //{ ccMechaItem = Spawn(class'UIMechaListItem', self); ccMechaItem.InitListItem(); ccMechaItem.SetPosition(0, 120); //} } simulated function PopulateData() { Super.PopulateData(); ccMechaItem.UpdateDataButton("Switch Class Button","Switch Class",UpdateCC); Super.PopulateData(); } function UpdateCC(UIButton ccButton) { local array<X2SoldierClassTemplate> Templates; local X2SoldierClassTemplateManager SoldierClassManager; local int rnd; SoldierClassManager = class'X2SoldierClassTemplateManager'.static.GetSoldierClassTemplateManager(); Templates= SoldierClassManager.GetAllSoldierClassTemplates(); rnd=RAND(Templates.length); `log("Switched Class to: " @Templates[rnd].DisplayName); //Unit.SetSoldierClassTemplate(Templates[rnd].DisplayName); } defaultproperties { b_UseCC = true } (in the ini) [Engine.Engine] +ModClassOverrides=(BaseGameClass="UIArmory_Promotion", ModClass="UIArmory_Promotion_CommandersChoice") Now, i have checked for leftover ModClassOverrides and i found none in my configs in the SDK folder, i would love a quick UI tutorial or some guidance. Thanks in advance for everyone! Edited February 19, 2016 by Guest Link to comment Share on other sites More sharing options...
davidlallen Posted February 19, 2016 Share Posted February 19, 2016 You are working in almost the same area as me. I hope to get somewhere on it this weekend. My specific goal is in this post:http://forums.nexusmods.com/index.php?/topic/3818995-after-hotfix-some-sdk-uc-files-dont-compile/page-2&do=findComment&comment=34752450BTW, the problem with leftover overrides is in your *local* XcomEngine.ini, that is <username>/My Documents/My Games/XCOM 2/XcomGame/XComEngine.ini. Not the one in your sdk directory. Link to comment Share on other sites More sharing options...
Amineri Posted February 19, 2016 Share Posted February 19, 2016 I don't think I'd try to override UIArmory_Promotion for what you are trying to do -- it seems a bit like overkill. All you are doing is adding a button that does something on callback, so why not use a UIScreenListener that is listening to UIArmory_Promotion instead? This is basically what they are best at. Plus there can be any number of ScreenListeners, so your mod won't interfere with other mods that also add stuff to promotion. Define your UIMechaListItem in the screen listener, and create it in the OnInit. Don't attach it to self, though, attach it to the screen. My first implementation for accessing officer promotion UI dropped a floating button in, and looked like : //--------------------------------------------------------------------------------------- // FILE: UIScreenListener_Armor_Promotion_LWOfficerPack // AUTHOR: Amineri // // PURPOSE: Implements hooks to initiate Officer UI based on UIArmory classes // TODO: Remove if MainMenu insertion is made to work //--------------------------------------------------------------------------------------- class UIScreenListener_Armory_Promotion_LWOfficerPack extends UIScreenListener; var UIButton OfficerButton; var UIArmory_Promotion ParentScreen; var localized string strOfficerMenuOption; // This event is triggered after a screen is initialized event OnInit(UIScreen Screen) { ParentScreen = UIArmory_Promotion(Screen); AddFloatingButton(); } // This event is triggered after a screen receives focus event OnReceiveFocus(UIScreen Screen) { ParentScreen = UIArmory_Promotion(Screen); AddFloatingButton(); } // This event is triggered after a screen loses focus event OnRemoved(UIScreen Screen) { ParentScreen = none; // clean up to allow GC } function AddFloatingButton() { OfficerButton = ParentScreen.Spawn(class'UIButton', ParentScreen); OfficerButton.InitButton('', Caps(strOfficerMenuOption), OnButtonCallback, eUIButtonStyle_HOTLINK_BUTTON); OfficerButton.SetResizeToText(false); OfficerButton.SetFontSize(24); OfficerButton.SetPosition(140, 80); OfficerButton.SetSize(280, 40); OfficerButton.Show(); } simulated function OnButtonCallback(UIButton kButton) { local XComHQPresentationLayer HQPres; local UIArmory_LWOfficerPromotion OfficerScreen; HQPres = `HQPRES; OfficerScreen = UIArmory_LWOfficerPromotion(HQPres.ScreenStack.Push(HQPres.Spawn(class'UIArmory_LWOfficerPromotion', HQPres), HQPres.Get3DMovie())); OfficerScreen.InitPromotion(ParentScreen.GetUnitRef(), false); } defaultproperties { // Leaving this assigned to none will cause every screen to trigger its signals on this class ScreenClass = UIArmory_Promotion; } Link to comment Share on other sites More sharing options...
TeamDragonpunk Posted February 19, 2016 Share Posted February 19, 2016 Well that answers the question in my thread about how to use UI Listeners correctly. Link to comment Share on other sites More sharing options...
Deleted32045420User Posted February 19, 2016 Author Share Posted February 19, 2016 (edited) Thanks Everyone! Worked perfectly Amineri, what would we do without you :laugh: Edited February 19, 2016 by Guest Link to comment Share on other sites More sharing options...
davidlallen Posted February 19, 2016 Share Posted February 19, 2016 Hm, if a real commanders choice button is available, my smaller goal is not so important. (That is fine, I have lots of ideas.) If you publish, please leave a comment in the first workshop mod so that people know about yours: http://steamcommunity.com/sharedfiles/filedetails/?id=627247537&searchtext=commanders Link to comment Share on other sites More sharing options...
Deleted32045420User Posted February 20, 2016 Author Share Posted February 20, 2016 Thank you all, i have sorted out all the problems and Commander's Choice is now up. Hm, if a real commanders choice button is available, my smaller goal is not so important. (That is fine, I have lots of ideas.) If you publish, please leave a comment in the first workshop mod so that people know about yours: http://steamcommunity.com/sharedfiles/filedetails/?id=627247537&searchtext=commandersi've put a message there. Link to comment Share on other sites More sharing options...
davidlallen Posted February 20, 2016 Share Posted February 20, 2016 That's great. FWIW there is a set of mods on workshop that also use the name "SWR", for "Second Wave Remastered". Maybe you can combine forces. Link to comment Share on other sites More sharing options...
Deleted32045420User Posted February 20, 2016 Author Share Posted February 20, 2016 That's great. FWIW there is a set of mods on workshop that also use the name "SWR", for "Second Wave Remastered". Maybe you can combine forces.i talked to the guy who makes SWR- his NCE is based on my code and our ideas are a bit different- i am aiming for new and adapted more long war like second wave options he's going for EW style SW options. I am also going for a single mod to reduce thread bulk and inter compatibility issues and he's doing a more modular approach that allows him to do some stuff i cant (at least easily) Link to comment Share on other sites More sharing options...
Zyxpsilon Posted February 20, 2016 Share Posted February 20, 2016 (edited) Can these sort of Listener principles be "attached" to some indirect layer where Scaleform resources are interacted with--IN the Geoscape flow of gameplay events?Instead of having to rewrite the usual gfx components like the necessary 1) SWF customization steps & 2) relatively complex script event hooks. Approximately, somehow. Edited February 20, 2016 by Zyxpsilon Link to comment Share on other sites More sharing options...
Recommended Posts