Page 2 of 2

Re: Change character look

Posted: Thu May 16, 2024 9:38 am
by Antison
Lam al Adie wrote: Thu May 16, 2024 8:39 am
Nut wrote: Thu May 16, 2024 8:21 am Hi Odin,
to change an existing character into a new one - what should it do? Forget all quests, items, skills and xp, so that you can replay the game?
I think, he meant to change the sprite…

It would be nice to have that possibility and a load of additional sprites for the li'l guy, so you can change the look according to you gear/weapon preference.
Or to have that changed automatically, when yor switch from light to heavy armor or such.

On the other hand I appreciate your concentration on developing more content than on changes to the game engine.
https://www.andorstrail.com/viewtopic.p ... 7&start=40
Page 5

Re: Change character look

Posted: Thu May 16, 2024 10:27 am
by Lam al Adie
Antison wrote: Thu May 16, 2024 9:38 am https://www.andorstrail.com/viewtopic.p ... 7&start=40
Page 5
Yes, thanks, I have seen that post some days ago.
But the question here went beyond having more choices for a new character: it's about possibilities to change the look of your existing character during gameplay, with my addition of doing so automatically.

But as I said, if I were Dev, I probably would not put much effort into such a feature before we all have found Andor.

Re: Change character look

Posted: Thu May 16, 2024 10:35 am
by Raphi
Theoretically this should be possible. When creating a new savegame, the WorldSetup.java calls the following function with "newHeroIcon" as an attribute.

src/.../AndorsTrail/WorldSetup.java/155

Code: Select all

world.model.player.initializeNewPlayer(world.dropLists, newHeroName, newHeroIcon);

The called function defines this newHeroIcon as an iconID:

src/.../AndorsTrail/model/actor/Player.java/105

Code: Select all

baseTraits.iconID = playerIcon;

If you would create a method in Player.java like

Code: Select all

private void updatePlayerIcon(int playerIcon) {
	baseTraits.iconID = playerIcon;
}
this should update the Player's character Icon. However, I do not know how AT saves these information into a savegame file, I guess my suggenstion would only change the icon during a running game but not save the change to the actual savegame file.

Re: Change character look

Posted: Thu May 16, 2024 10:47 am
by Raphi
The question would be, where would you put the option to change your look ingame. I would either put a button over the character in the inventory:
Change_Icon_Location.jpg
or in the character's overview:
Change_Icon_Location_2.jpg
This button could then open a popup menu with all possible character sprites (excluding the ones that would be used ingabe for e.g. turning the player into a toad etc.)

Choosing a character sprite by clicking on it would then trigger the updatePlayerIcon method with the respective integer as an attribute.

Re: Change character look

Posted: Thu May 16, 2024 11:03 am
by Antison
Lam al Adie wrote: Thu May 16, 2024 10:27 am
Antison wrote: Thu May 16, 2024 9:38 am https://www.andorstrail.com/viewtopic.p ... 7&start=40
Page 5
Yes, thanks, I have seen that post some days ago.
But the question here went beyond having more choices for a new character: it's about possibilities to change the look of your existing character during gameplay, with my addition of doing so automatically.

But as I said, if I were Dev, I probably would not put much effort into such a feature before we all have found Andor.
You didn't read the post in that link that I made
Screenshot_20240516-070523.png

Re: Change character look

Posted: Thu May 16, 2024 11:04 am
by Odin
Raphi wrote: Thu May 16, 2024 10:47 am The question would be, where would you put the option to change your look ingame. I would either put a button over the character in the inventory:


or in the character's overview:


This button could then open a popup menu with all possible character sprites (excluding the ones that would be used ingabe for e.g. turning the player into a toad etc.)

Choosing a character sprite by clicking on it would then trigger the updatePlayerIcon method with the respective integer as an attribute.
Either way would be a usefull option for older characters.

Re: Change character look

Posted: Thu May 16, 2024 12:38 pm
by Lam al Adie
Antison wrote: Thu May 16, 2024 11:03 am You didn't read the post in that link that I made

Screenshot_20240516-070523.png
I sure did, but did not understand it the way you seem to have intended.

Re: Change character look

Posted: Thu May 16, 2024 12:43 pm
by Raphi
Don't mind my posts, I'm just collecting ideas on how this could be done :roll:

Let's say we want to put it in the inventory tab. We would have to take a look at the following file:

AndorsTrail/res/layout/heroinfo_equipped.xml

On line 14-20, the Character's sprite is shown. If this could be used for an onClick function of some sort, this should be quite easy without huge changes.


This could be done very similar on how the worn items are clickable:

src/.../AndorsTrail/activity/fragment/HeroinfoActivity_Inventory.java:171

Code: Select all

imageView.setOnClickListener(new OnClickListener() {
	@Override
	public void onClick(View v) {
		if (player.inventory.isEmptySlot(inventorySlot)) return;
		imageView.setClickable(false); // Will be enabled again on update()
		showEquippedItemInfo(player.inventory.getItemTypeInWearSlot(inventorySlot), inventorySlot);
	}
});

This would look something like this:

Code: Select all

imageView.setOnClickListener(new OnClickListener() {
	@Override
	public void onClick(View v) {
		showCharacterIconSelection();
	}
});

Of course, what's missing still is the menu itself, where the player can choose the sprite. I have not yet figured out how to do that, unfortunately.

Code: Select all

private void showCharacterIconSelection() {
	// Show a new inflated window with either a vertical list or a grid containing all chooseable character sprites
	// Each element of the list/grid has to have an onClick function itself, which calls player.updatePlayerIcon(spriteID);
	// Problem: How to define which spriteID would be called for each button?
}
Edit: If I find the time for it, I will try implementing this function and, if it actually works, I can do a pull request for it on GitHub ;)

Re: Change character look

Posted: Thu May 16, 2024 12:56 pm
by Lam al Adie
:twisted: See me doing Ballmers developers-dance for you.