Custom portraits for individual mods?

A refuge for those migrating from the fallen DXEditing.com and a place for general discussion relating to Deus Ex editing (coding, mapping, etc).
Post Reply
binos1515
Mole Person
Posts: 8
Joined: Wed Sep 18, 2019 7:06 pm

Custom portraits for individual mods?

Post by binos1515 »

I know how to have custom portraits that change the character appearance at the start of the game for the regular game or the whole of the Mod Loader, but how would you do it for individual mods?
Create a function or modify something in MLMenuSreenNewGame.uc? Or create an extension for that class or MenuSreenNewGame.uc in my package?

The first part of this if statement in MLMenuSreenNewGame sort of seems like it could be used do something but I'm too new at coding to tell:

function ResetToDefaults()
{
if ((MLGameInfo(player.DXGame).ModDescription!="")&&(bMLWinInit)){
...
}

I tried changing != to == and adding a description from my .int file but it didn't work.

Not that big of deal since I'm probably never gonna make more than one mod, just a coding curiosity.
binos1515
Mole Person
Posts: 8
Joined: Wed Sep 18, 2019 7:06 pm

Re: Custom portraits for individual mods?

Post by binos1515 »

So in MLMenuScreeNewGame.uc, I found out that InitWindow() sets what the portrait image is by calling ResetToDefaults(), which is the same function that the Reset Defaults button in the menu uses.

I tried to add IF ELSE and putting the different set of textures in the same defaultproperties, am able to compile without errors but seem to get the else statement since I get that set of heads (texPortraits).

I've tried a bunch of different things where "if (????? == thingInMyMod)" is below but just not sure what to put to pull things from my int file.
// ----------------------------------------------------------------------
// ResetToDefaults()
//
// Meant to be called in derived class
// ----------------------------------------------------------------------

function ResetToDefaults()
{
if ((MLGameInfo(player.DXGame).ModDescription!="")&&(bMLWinInit)){

editName.SetText(player.TruePlayerName);
player.SkillPointsAvail = MLSkillPoints;
player.SkillPointsTotal = MLSkillPoints;

portraitIndex = 0;

if (????? == thingInMyMod){

btnPortrait.SetBackground(newPortraits[portraitIndex]);

}else{

btnPortrait.SetBackground(texPortraits[portraitIndex]);
}


setSkillLevels();
PopulateSkillsList();
UpdateSkillPoints();
EnableButtons();
}else{
Super.ResetToDefaults();
}

defaultproperties
{
texPortraits(0)=Texture'DeusExUI.UserInterface.MenuNewGameJCDenton_4'
texPortraits(1)=Texture'DeusExUI.UserInterface.MenuNewGameJCDenton_2'
texPortraits(2)=Texture'DeusExUI.UserInterface.MenuNewGameJCDenton_3'
texPortraits(3)=Texture'DeusExUI.UserInterface.MenuNewGameJCDenton_4'
texPortraits(4)=Texture'DeusExUI.UserInterface.MenuNewGameJCDenton_5'

newPortraits(0)=Texture'DeusExUI.UserInterface.MenuNewGameJCDenton_3'
newPortraits(1)=Texture'DeusExUI.UserInterface.MenuNewGameJCDenton_1'
newPortraits(2)=Texture'DeusExUI.UserInterface.MenuNewGameJCDenton_3'
newPortraits(3)=Texture'DeusExUI.UserInterface.MenuNewGameJCDenton_4'
newPortraits(4)=Texture'DeusExUI.UserInterface.MenuNewGameJCDenton_5'
}
binos1515
Mole Person
Posts: 8
Joined: Wed Sep 18, 2019 7:06 pm

Re: Custom portraits for individual mods?

Post by binos1515 »

I finally got it -

Turns out only MenuScreenNewGame.uc calls ResetToDefaults() in InitWindow();
MLMenuScreenNewGame.uc calls Super.InitWindow() which feeds its defaultproperties to the initial ResetToDefaults() in MenuScreenNewGame.

My solution was to copy over the InitWindow() and ResetToDefaults() functions in MLMenuScreenNewGame to be the same as in MenuScreenNewGame (and added other necessary functions);
then in that ResetToDefaults(), I added a condition to check IF (player.SkillPointsAvail==0) since my mod starts with 0 skill points from the .int file;
if so, it sets background to one portrait array, else it sets it to another array, using btnPortrait.SetBackground(xPortraits[portraitIndex]).

First problem was that you can't get a value for player.SkillPointsAvail unless a bunch of other functions are ran first, so I threw ResetToDefaults() at the end of InitWindow();
second is the PreviousPortrait() and NextPortrait() functions work on only one array, so in the successfull IF above in ResetToDefaults() I made a bool True;
then added an IF bool True in the two previous functions to tell it which one to work to work on, so that it doesn't change the portraits to the another array.

The problem with that is that for the mods that aren't mine, it still ends up changing the array since the amount of skill points goes back to being 0 even if it isn't once the mod is loaded;
thus you have to call GetModSkillsandPoints() at the beginning of ResetToDefaults() for the IF (player.SkillPointsAvail==0) to always work.

Of course there are probably better ways than checking for skill points since more than one mod could have 0 skill points;
I've found out about Access methods like inStr and Mid and such so I'll probably experiment with those and post my code when I've cleaned it up.
binos1515
Mole Person
Posts: 8
Joined: Wed Sep 18, 2019 7:06 pm

Re: Custom portraits for individual mods?

Post by binos1515 »

Here is is, I only copied the things I changed in MLMenuScreenNewGame.uc

Also the way this works you want to have the texture import for the new textures in the DeusExML folder
//-----------------------------------------------------------
//
//-----------------------------------------------------------
class MLMenuScreenNewGame expands MenuScreenNewGame;

var int MLSkillPoints;
var int MLSkillLevels[15];
var bool bMLWinInit;
var Texture MLPortraits[5];
var Texture ModPortraits[5];
var bool isMyMod;


// ----------------------------------------------------------------------
// InitWindow()
//
// Initialize the Window
// ----------------------------------------------------------------------

event InitWindow()
{
Super.InitWindow();

SaveSkillPoints();
GetModSkillsandPoints();

bMLWinInit=True;

ResetToDefaults();

SetSkillLevels();
PopulateSkillsList();
UpdateSkillPoints();

}

// ----------------------------------------------------------------------
// ResetToDefaults()
//
// Meant to be called in derived class
// ----------------------------------------------------------------------

function ResetToDefaults()
{
local int myModPos;

UpdateSkillPoints();


if ((MLGameInfo(player.DXGame).ModDescription!="")&&(bMLWinInit)){

editName.SetText(player.TruePlayerName);

player.SkillPointsAvail = MLSkillPoints;
player.SkillPointsTotal = MLSkillPoints;

portraitIndex=0;

myModPos=inStr(Caps(MLGameInfo(player.DXGame).ModDescription), "MYMOD");

if(myModPos>=0)[/b][/size]{
btnPortrait.SetBackground(ModPortraits[portraitIndex]);
isMyMod=True;
}else{
btnPortrait.SetBackground(MLPortraits[portraitIndex]);
}
}else{
Super.ResetToDefaults();
}
}

// ----------------------------------------------------------------------
// PreviousPortrait()
// ----------------------------------------------------------------------

function PreviousPortrait()
{
portraitIndex--;

if(isMyMod){

if (portraitIndex < 0)
portraitIndex = arrayCount(ModPortraits) - 1;

btnPortrait.SetBackground(ModPortraits[portraitIndex]);
}else{
if (portraitIndex < 0)
portraitIndex = arrayCount(MLPortraits) - 1;

btnPortrait.SetBackground(MLPortraits[portraitIndex]);
}
}

// ----------------------------------------------------------------------
// NextPortrait()
// ----------------------------------------------------------------------

function NextPortrait()
{
portraitIndex++;

if(isMyMod){
if (portraitIndex == arrayCount(ModPortraits))
portraitIndex = 0;

btnPortrait.SetBackground(ModPortraits[portraitIndex]);
}else{
if (portraitIndex == arrayCount(MLPortraits))
portraitIndex = 0;

btnPortrait.SetBackground(MLPortraits[portraitIndex]);
}
}

// ----------------------------------------------------------------------
// ----------------------------------------------------------------------

defaultproperties
{
MLPortraits(0)=Texture'DeusExUI.UserInterface.MenuNewGameJCDenton_5'
MLPortraits(1)=Texture'DeusExUI.UserInterface.MenuNewGameJCDenton_4'
MLPortraits(2)=Texture'DeusExUI.UserInterface.MenuNewGameJCDenton_3'
MLPortraits(3)=Texture'DeusExUI.UserInterface.MenuNewGameJCDenton_2'
MLPortraits(4)=Texture'DeusExUI.UserInterface.MenuNewGameJCDenton_1'
ModPortraits(0)=Texture'DeusExML.Portraits.MyPortrait1'
ModPortraits(1)=Texture'DeusExML.Portraits.MyPortrait2'
ModPortraits(2)=Texture'DeusExML.Portraits.MyPortrait3'
ModPortraits(3)=Texture'DeusExML.Portraits.MyPortrait4'
ModPortraits(4)=Texture'DeusExML.Portraits.MyPortrait5'

}
Post Reply