Applied jarod's patches.

This commit is contained in:
nobody_ 2004-01-30 15:52:13 +00:00
parent 34b8c6e580
commit 6d662a2be2
4 changed files with 38 additions and 29 deletions

View file

@ -73,6 +73,10 @@ extern void DoScrollArea(enum _scroll_state_ state, int fast);
-- Variables
----------------------------------------------------------------------------*/
global int IconWidth; /// Icon width in panels
global int IconHeight; /// Icon height in panels
global char EditorRunning; /// True editor is running
global char EditorMapLoaded; /// Map loaded in editor
@ -345,13 +349,39 @@ local int CalculateUnitIcons(void)
x += IconHeight + 2;
}
x = TheUI.ButtonPanelX + 10;
while (x < TheUI.ButtonPanelX + 146) {
while (x < TheUI.ButtonPanelX + TheUI.ButtonPanel.Graphic->Width) {
count += i;
x += IconWidth + 8;
}
return count;
}
/**
** Calculate the max height and the max widht of icons,
** and assign them to IconHeight and IconWidth
*/
local void CalculateMaxIconSize()
{
int i;
const UnitType* type;
const Icon* icon;
IconWidth = 0;
IconHeight = 0;
for (i = 0; i < MaxUnitIndex; ++i) {
type = UnitTypeByIdent(EditorUnitTypes[i]);
DebugCheck(!type || !type->Icon.Icon);
icon = type->Icon.Icon;
if (IconWidth < icon->Width) {
IconWidth = icon->Width;
}
if (IconHeight < icon->Height) {
IconHeight = icon->Height;
}
}
}
/**
** Recalculate the shown units.
*/
@ -620,15 +650,14 @@ local void DrawUnitIcons(void)
// Draw the unit icons.
//
y = TheUI.ButtonPanelY + 24;
i = UnitIndex;
while (y < TheUI.ButtonPanelY +
640/3 - IconHeight) {
while (y < TheUI.ButtonPanelY + TheUI.ButtonPanel.Graphic->Height
- IconHeight) {
if (i >= MaxShownUnits) {
break;
}
x = TheUI.ButtonPanelX + 10;
while (x < TheUI.ButtonPanelX + 146) {
while (x + IconWidth < TheUI.ButtonPanelX + TheUI.ButtonPanel.Graphic->Width) {
if (i >= MaxShownUnits) {
break;
}
@ -1930,7 +1959,7 @@ local void CreateEditor(void)
}
MaxUnitIndex = n - 1;
}
CalculateMaxIconSize();
ShowUnitsToSelect = 1; // Show all units as default
ShowBuildingsToSelect = 1;
#if 0

View file

@ -176,8 +176,8 @@ typedef struct _icon_ {
IconFile* File; /// File containing the data
unsigned Index; /// Index into file
unsigned Width; /// Icon width
unsigned Height; /// Icon height
int Width; /// Icon width
int Height; /// Icon height
// --- FILLED UP ---
Graphic* Sprite; /// Graphic data loaded

View file

@ -57,10 +57,6 @@
*/
global char** IconWcNames;
// FIXME: Can be removed:
global int IconWidth; /// Icon width in panels
global int IconHeight; /// Icon height in panels
local Icon** Icons; /// Table of all icons.
local int NumIcons; /// Number of icons in Icons.
@ -578,20 +574,6 @@ local int CclDefineIconWcNames(lua_State* l)
return 0;
}
/**
** Set icon size
** FIXME: can be removed:
*/
local int CclSetIconSize(lua_State* l)
{
if (lua_gettop(l) != 2) {
lua_pushstring(l, "incorrect argument");
lua_error(l);
}
IconWidth = LuaToNumber(l, 1);
IconHeight = LuaToNumber(l, 2);
return 0;
}
/**
** Register CCL features for icons.
@ -604,9 +586,6 @@ global void IconCclRegister(void)
lua_register(Lua, "DefineIconAlias", CclDefineIconAlias);
lua_register(Lua, "DefineIconWcNames", CclDefineIconWcNames);
// FIXME: can be removed:
lua_register(Lua, "SetIconSize", CclSetIconSize);
}
//@}

View file

@ -820,6 +820,7 @@ local int CclDefineModifier(lua_State* l)
convert_to = UnitTypeByIdent(value);
} else {
lua_pushfstring(l, "wrong tag: %s", temp);
lua_error(l);
return 0;
}
}