Need Python help please !!

frenchman

Present is past of future
Joined
Aug 15, 2003
Messages
1,039
Hello,

I try to change the size of the icons in the civilopedia.
The first step, I change the "self.ICON_SIZE = 64 to 160" in CvPediaBonus.
It works, I have a bigger icon for the resource (Aluminium), so I increase the size of the dds file in order to have a beautiful picture (I create a new one) ==> it works

The problem comes when I go to the Unit civilopedia screen.For the modern tank I use the resource... And in the screen the icon has the size of the dds file (too big), it seems that the code in the CvPediaUnit is "GenericButtonSizes.BUTTON_SIZE_CUSTOM" but I tried, without success, to change this to have a 64 size...
To summarize I would like to have a 160x160 dds resource icon which appears at this size in the resource screen (it works) and at the size of 64 in the Unit screen (doesn't work for the moment...)
Does someone know how to proceed ? :thanx:
 
frenchman said:
Hello,

I try to change the size of the icons in the civilopedia.
The first step, I change the "self.ICON_SIZE = 64 to 150" in CvPediaBonus.
It works, I have a bigger icon for the resource (Aluminium), so I increase the size of the dds file in order to have a beautiful picture (I create a new one) ==> it works

The problem comes when I go to the Unit civilopedia screen.For the modern tank I use the resource... And in the screen the icon has the size of the dds file (to big), it seems that the code in the CvPediaUnit is "GenericButtonSizes.BUTTON_SIZE_CUSTOM" but I tried, without success, to change this to have a 64 size...
To summarize I would like to have a 160x160 dds file which appears at this size in the resource screen (it works) and at the size of 64 in the Unit screen (doesn't work for the moment...)
Does someone know how to proceed ? :thanx:

I think you're looking at the wrong place. I think this is the line that uses the size of the icon:

Code:
screen.addDDSGFC(self.top.getNextWidgetName(), gc.getUnitInfo(self.iUnit).getButton(),
		    self.X_ICON + self.W_ICON/2 - self.ICON_SIZE/2, self.Y_ICON + self.H_ICON/2 - self.ICON_SIZE/2, self.ICON_SIZE, self.ICON_SIZE, WidgetTypes.WIDGET_GENERAL, -1, -1 )

It should be line 104. Looks like they use self.ICON_SIZE. I haven't tried this on my own so I don't know if it's correct, but you can give it a try.
 
:thanx: for your help, I think that the chapter for the resource in the unit screen is at "# add resource buttons" and " # count the number of OR resources" levels... But I'm not sure...
The chapter you describe seems to me more for the Unit icon, but I will try ... I'm perhaps wrong...
:thanx:
 
frenchman said:
:thanx: for your help, I think that the chapter for the resource in the unit screen is at "# add resource buttons" and " # count the number of OR resources" levels... But I'm not sure...
The chapter you describe seems to me more for the Unit icon, but I will try ... I'm perhaps wrong...
:thanx:

Oh. I think you wanted to resize that unit button. lol

Well, taking a second look, it seems there are two places that a "bonus" button gets put on the screen, so you might need to have both places covered?

Also, are you trying to actually change GenericButtonSizes.BUTTON_SIZE_CUSTOM to another value? I would try making your own value (like NEW_BUTTON_SIZE, or FRENCHMAN_BUTTON_SIZE) and setting that to a value, then using that. Or, you can just put the number right in the code to replace the GenricButtonSizes.BUTTON_SIZE_CUSTOM. Considered bad coding practice, but oh well.
 
Gerikes said:
Oh. I think you wanted to resize that unit button. lol

Well, taking a second look, it seems there are two places that a "bonus" button gets put on the screen, so you might need to have both places covered?

Also, are you trying to actually change GenericButtonSizes.BUTTON_SIZE_CUSTOM to another value? I would try making your own value (like NEW_BUTTON_SIZE, or FRENCHMAN_BUTTON_SIZE) and setting that to a value, then using that. Or, you can just put the number right in the code to replace the GenricButtonSizes.BUTTON_SIZE_CUSTOM. Considered bad coding practice, but oh well.
I have already tried to put a number, but I never tried to put a new code like "FRENCHMAN_BUTTON_SIZE", it's a good idea I will try...
:thanx:
 
frenchman said:
I have already tried to put a number, but I never tried to put a new code like "FRENCHMAN_BUTTON_SIZE", it's a good idea I will try...
:thanx:

Well, it should theoretically do the same thing. But perhaps you never changed this line...

Code:
for j in range(gc.getNUM_UNIT_PREREQ_OR_BONUSES()):
	eBonus = gc.getUnitInfo(self.iUnit).getPrereqOrBonuses(j)
	if (eBonus > -1):
		if (not bFirst):
			screen.attachLabel(panelName, "", localText.getText("TXT_KEY_OR", ()))
		else:
			bFirst = False
		[b]screen.attachImageButton( panelName, "", gc.getBonusInfo(eBonus).getButton(), GenericButtonSizes.BUTTON_SIZE_CUSTOM, WidgetTypes.WIDGET_PEDIA_JUMP_TO_BONUS, eBonus, -1, False )			[/b]

That was on line 218, slightly above the comment "# add religion buttons"
 
I have tried (and changed the 4 concerned lines (techs + resources) in the same panel)

- to create a "self.frenchman_button_size=64" or others codes==> doesn't work, I don't see the resource or tech anymore
- to put a number alone ==> doesn't work, idem
- to put 2 numbers " 64, 64" ==> doesn't work, idem
- to put a number after "GenericButtonSizes." ==> doesn't work idem

The software seems to take the size of the dds icon without changes, I have tried with a 32x32 dds icon and the resource appears at this size in the panel... In the resource screen the icon size code increases the size, the 32x32 dds file appears with a 160x160 size in the screen...

:thanx:
 
Hello Gerikes,

I have found the solution, the Genericbuttonsizes accept only some sizes, and the 64x64 is not one accepted, it's why my tests were not working.
Now I put Genericbuttonsizes.BUTTON_SIZE_46 and it works... Have a look to my library to see the new tech icons I have created with a 160x160 size...
:thanx: for your help...
 
frenchman said:
Hello Gerikes,

I have found the solution, the Genericbuttonsizes accept only some sizes, and the 64x64 is not one accepted, it's why my tests were not working.
Now I put Genericbuttonsizes.BUTTON_SIZE_46 and it works... Have a look to my library to see the new tech icons I have created with a 160x160 size...
:thanx: for your help...

Ahhh, I see. I should have caught on to that earlier.

Knowing that though, I've taken a look at where the different values are defined. Here they are:

BUTTON_SIZE_46,
BUTTON_SIZE_32,
BUTTON_SIZE_24,
BUTTON_SIZE_16,
BUTTON_SIZE_CUSTOM

Maybe you can do something with BUTTON_SIZE_CUSTOM if any of the defaults don't work well for you.
 
Back
Top Bottom