[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Stratagus-CVS] stratagus/src include/stratagus.h stratagus/str...
From: |
address@hidden |
Subject: |
[Stratagus-CVS] stratagus/src include/stratagus.h stratagus/str... |
Date: |
23 Dec 2003 16:30:18 +1100 |
CVSROOT: /home/strat
Module name: stratagus
Changes by: <address@hidden> 03/12/23 16:30:17
Modified files:
src/include : stratagus.h
src/stratagus : stratagus.c
src/ui : ccl_ui.c
Log message:
Clean up
Patches:
Index: stratagus/src/include/stratagus.h
diff -u stratagus/src/include/stratagus.h:1.30
stratagus/src/include/stratagus.h:1.31
--- stratagus/src/include/stratagus.h:1.30 Mon Dec 22 19:01:26 2003
+++ stratagus/src/include/stratagus.h Tue Dec 23 16:30:15 2003
@@ -26,7 +26,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: stratagus.h,v 1.30 2003/12/22 08:01:26 wizzard Exp $
+// $Id: stratagus.h,v 1.31 2003/12/23 05:30:15 jsalmon3 Exp $
#ifndef __STRATAGUS_H__
#define __STRATAGUS_H__
@@ -451,9 +451,10 @@
typedef struct _title_screen_label_ {
char* Text;
- int xofs;
- int yofs;
- int flags;
+ int Font;
+ int Xofs;
+ int Yofs;
+ int Flags;
} TitleScreenLabel;
typedef struct _title_screen_ {
Index: stratagus/src/stratagus/stratagus.c
diff -u stratagus/src/stratagus/stratagus.c:1.238
stratagus/src/stratagus/stratagus.c:1.239
--- stratagus/src/stratagus/stratagus.c:1.238 Mon Dec 22 19:01:27 2003
+++ stratagus/src/stratagus/stratagus.c Tue Dec 23 16:30:16 2003
@@ -26,7 +26,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: stratagus.c,v 1.238 2003/12/22 08:01:27 wizzard Exp $
+// $Id: stratagus.c,v 1.239 2003/12/23 05:30:16 jsalmon3 Exp $
//@{
@@ -1296,7 +1296,6 @@
int j;
int x;
int y;
- float ratio;
PrintHeader();
printf(
@@ -1340,37 +1339,25 @@
}
if (PlayMovie(TitleScreens[i]->File,
PlayMovieZoomScreen |
PlayMovieKeepAspect)) {
+ TitleScreenLabel** labels;
+
DisplayPicture(TitleScreens[i]->File);
- if (TitleScreens[i]->Labels) {
- if (VideoDepth &&
IsFontLoaded(SmallFont) &&
- IsFontLoaded(GameFont) &&
IsFontLoaded(LargeFont)) {
+ labels = TitleScreens[i]->Labels;
+ if (labels && labels[0] &&
IsFontLoaded(labels[0]->Font)) {
#ifndef USE_SDL_SURFACE
- VideoLockScreen();
+ VideoLockScreen();
#endif
- for (j = 0;
TitleScreens[i]->Labels[j]; ++j) {
- if (VideoWidth == 640) {
- x =
TitleScreens[i]->Labels[j]->xofs;
- y =
TitleScreens[i]->Labels[j]->yofs;
- } else {
- ratio = (float)
VideoWidth / 640.0;
- x = ratio *
TitleScreens[i]->Labels[j]->xofs;
- y = ratio *
TitleScreens[i]->Labels[j]->yofs;
- }
- if
(TitleScreens[i]->Labels[j]->flags & TitleFlagCenter) {
- x +=
VideoWidth/2;
- }
- if (VideoWidth == 640) {
-
VideoDrawTextCentered(x, y, GameFont, TitleScreens[i]->Labels[j]->Text);
- } else if (VideoWidth
== 800) {
-
VideoDrawTextCentered(x, y, GameFont, TitleScreens[i]->Labels[j]->Text);
- } else {
-
VideoDrawTextCentered(x, y, LargeFont, TitleScreens[i]->Labels[j]->Text);
- }
+ for (j = 0; labels[j]; ++j) {
+ x = labels[j]->Xofs *
VideoWidth / 640;
+ y = labels[j]->Yofs *
VideoWidth / 640;
+ if (labels[j]->Flags &
TitleFlagCenter) {
+ x -=
VideoTextLength(labels[j]->Font, labels[j]->Text) / 2;
}
+ VideoDrawText(x, y,
labels[j]->Font, labels[j]->Text);
+ }
#ifndef USE_SDL_SURFACE
- VideoUnlockScreen();
+ VideoUnlockScreen();
#endif
- }
}
Invalidate();
WaitForInput(TitleScreens[i]->Timeout);
@@ -1378,10 +1365,10 @@
}
}
- InitUnitsMemory(); // Units memory
management
- PreMenuSetup(); // Load everything needed for
menus
+ InitUnitsMemory(); // Units memory management
+ PreMenuSetup(); // Load everything needed for menus
- MenuLoop(MapName, &TheMap); // Enter the menu loop
+ MenuLoop(MapName, &TheMap); // Enter the menu loop
return 0;
}
Index: stratagus/src/ui/ccl_ui.c
diff -u stratagus/src/ui/ccl_ui.c:1.175 stratagus/src/ui/ccl_ui.c:1.176
--- stratagus/src/ui/ccl_ui.c:1.175 Tue Dec 23 11:43:39 2003
+++ stratagus/src/ui/ccl_ui.c Tue Dec 23 16:30:16 2003
@@ -5,12 +5,12 @@
// /_______ /|__| |__| (____ /__| (____ /\___ /|____//____ >
// \/ \/ \//_____/ \/
// ______________________ ______________________
-// T H E W A R B E G I N S
-// Stratagus - A free fantasy real time strategy game engine
+// T H E W A R B E G I N S
+// Stratagus - A free fantasy real time strategy game engine
//
-/address@hidden ccl_ui.c - The ui ccl functions. */
+/address@hidden ccl_ui.c - The ui ccl functions. */
//
-// (c) Copyright 1999-2004 by Lutz Sammer, Jimmy Salmon, Martin Renold
+// (c) Copyright 1999-2004 by Lutz Sammer, Jimmy Salmon, Martin Renold
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
@@ -26,7 +26,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: ccl_ui.c,v 1.175 2003/12/23 00:43:39 jsalmon3 Exp $
+// $Id: ccl_ui.c,v 1.176 2003/12/23 05:30:16 jsalmon3 Exp $
//@{
@@ -69,10 +69,11 @@
/**
-** Enable/disable the global color cycling.
+** Enable/disable the global color cycling.
**
-** @param flag True = turn on, false = off.
-** @return The old state of color cylce
all.
+** @param flag True = turn on, false = off.
+**
+** @return The old state of color cylce all.
*/
#if defined(USE_GUILE) || defined(USE_SIOD)
local SCM CclSetColorCycleAll(SCM flag)
@@ -110,10 +111,11 @@
#endif
/**
-** Set speed of middle-mouse scroll
+** Set speed of middle-mouse scroll
**
-** @param speed number of screen pixels per mouse pixel
-** @return The old value.
+** @param speed number of screen pixels per mouse pixel
+**
+** @return The old value.
*/
#if defined(USE_GUILE) || defined(USE_SIOD)
local SCM CclSetMouseScrollSpeedDefault(SCM speed)
@@ -143,10 +145,11 @@
#endif
/**
-** Set speed of ctrl-middle-mouse scroll
+** Set speed of ctrl-middle-mouse scroll
+**
+** @param speed number of screen pixels per mouse pixel
**
-** @param speed number of screen pixels per mouse pixel
-** @return The old value.
+** @return The old value.
*/
#if defined(USE_GUILE) || defined(USE_SIOD)
local SCM CclSetMouseScrollSpeedControl(SCM speed)
@@ -176,10 +179,11 @@
#endif
/**
-** Set which missile is used for right click
+** Set which missile is used for right click
**
-** @param missile missile name to use
-** @return old value
+** @param missile missile name to use
+**
+** @return old value
*/
#if defined(USE_GUILE) || defined(USE_SIOD)
local SCM CclSetClickMissile(SCM missile)
@@ -525,11 +529,11 @@
#endif
/**
-** Default title-screen.
+** Default title screens.
**
-** @param title SCM title. (nil reports only)
+** @param list FIXME: docu
**
-** @return None
+** @return None
*/
#if defined(USE_GUILE) || defined(USE_SIOD)
local SCM CclSetTitleScreens(SCM list)
@@ -550,7 +554,7 @@
if (TitleScreens[i]->Labels) {
for (j = 0; TitleScreens[i]->Labels[j]; ++j) {
free(TitleScreens[i]->Labels[j]->Text);
- free (TitleScreens[i]->Labels[j]);
+ free(TitleScreens[i]->Labels[j]);
}
free(TitleScreens[i]->Labels);
}
@@ -643,13 +647,12 @@
#elif defined(USE_LUA)
local int CclSetTitleScreens(lua_State* l)
{
+ const char* value;
int i;
- int j;
- int k;
- int tables;
int args;
+ int j;
int subargs;
- int narg;
+ int k;
if (TitleScreens) {
for (i = 0; TitleScreens[i]; ++i) {
@@ -658,7 +661,7 @@
if (TitleScreens[i]->Labels) {
for (j = 0; TitleScreens[i]->Labels[j]; ++j) {
free(TitleScreens[i]->Labels[j]->Text);
- free (TitleScreens[i]->Labels[j]);
+ free(TitleScreens[i]->Labels[j]);
}
free(TitleScreens[i]->Labels);
}
@@ -668,89 +671,91 @@
TitleScreens = NULL;
}
- tables = lua_gettop(l);
- TitleScreens = calloc(tables + 1, sizeof(*TitleScreens));
+ args = lua_gettop(l);
+ TitleScreens = calloc(args + 1, sizeof(*TitleScreens));
- for (i = 0; i < tables; ++i) {
- if (!lua_istable(l, i + 1)) {
+ for (j = 0; j < args; ++j) {
+ if (!lua_istable(l, j + 1)) {
lua_pushstring(l, "incorrect argument");
lua_error(l);
}
- TitleScreens[i] = calloc(1, sizeof(**TitleScreens));
- lua_pushstring(l, "Image");
- lua_gettable(l, i + 1);
- TitleScreens[i]->File = strdup(LuaToString(l, -1));
- lua_pop(l, 1);
- lua_pushstring(l, "Music");
- lua_gettable(l, i + 1);
- if (!lua_isnil(l, -1)) {
- TitleScreens[i]->Music = strdup(LuaToString(l, -1));
- }
- lua_pop(l, 1);
- lua_pushstring(l, "Timeout");
- lua_gettable(l, i + 1);
- if (!lua_isnil(l, -1)) {
- TitleScreens[i]->Timeout = LuaToNumber(l, -1);
- } else {
- TitleScreens[i]->Timeout = 20;
- }
- lua_pop(l,1);
- lua_pushstring(l, "Label");
- lua_gettable(l, i + 1);
- if (!lua_isnil(l, -1)) {
- if (!lua_istable(l, tables + 1)) {
- lua_pushstring(l, "incorrect argument");
- lua_error(l);
- }
- args = luaL_getn(l, tables + 1);
- lua_pushnil(l);
- TitleScreens[i]->Labels = calloc(args + 1,
sizeof(*TitleScreens[i]->Labels));
- j = 0;
- while (lua_next(l, tables + 1)) {
- k = lua_gettop(l);
- TitleScreens[i]->Labels[j] = calloc(1,
sizeof(**TitleScreens[i]->Labels));
- lua_pushstring(l, "Text");
- lua_gettable(l, k);
- TitleScreens[i]->Labels[j]->Text =
strdup(LuaToString(l, -1));
- lua_pop(l, 1);
- lua_pushstring(l, "Pos");
- lua_gettable(l, k);
- if (!lua_istable(l, k + 1)) {
+ TitleScreens[j] = calloc(1, sizeof(**TitleScreens));
+ TitleScreens[j]->Timeout = 20;
+ lua_pushnil(l);
+ while (lua_next(l, j + 1)) {
+ value = LuaToString(l, -2);
+ if (!strcmp(value, "Image")) {
+ TitleScreens[j]->File = strdup(LuaToString(l,
-1));
+ } else if (!strcmp(value, "Music")) {
+ TitleScreens[j]->Music = strdup(LuaToString(l,
-1));
+ } else if (!strcmp(value, "Timeout")) {
+ TitleScreens[j]->Timeout = LuaToNumber(l, -1);
+ } else if (!strcmp(value, "Labels")) {
+ if (!lua_istable(l, -1)) {
lua_pushstring(l, "incorrect argument");
lua_error(l);
- }
- if (luaL_getn(l, k + 1) != 2) {
- lua_pushstring(l, "you need two args to
give a position");
- lua_error(l);
}
- lua_rawgeti(l, k + 1, 1);
- TitleScreens[i]->Labels[j]->xofs =
LuaToNumber(l, -1);
- lua_pop(l, 1);
- lua_rawgeti(l, k + 1, 2);
- TitleScreens[i]->Labels[j]->yofs =
LuaToNumber(l, -1);
- lua_pop(l, 1);
- lua_pop(l, 1);
- lua_pushstring(l, "Flags");
- lua_gettable(l, k);
- if (!lua_isnil(l, -1)) {
- subargs = luaL_getn(l, k + 1);
- for (narg = 1; narg <= subargs; ++narg)
{
- lua_rawgeti(l, k + 1, narg);
- if (!strcmp (LuaToString(l,
-1), "center")) {
-
TitleScreens[i]->Labels[j]->flags |= TitleFlagCenter;
+ subargs = luaL_getn(l, -1);
+ TitleScreens[j]->Labels = calloc(subargs + 1,
sizeof(*TitleScreens[j]->Labels));
+ for (k = 0; k < subargs; ++k) {
+ lua_rawgeti(l, -1, k + 1);
+ if (!lua_istable(l, -1)) {
+ lua_pushstring(l, "incorrect
argument");
+ lua_error(l);
+ }
+ TitleScreens[j]->Labels[k] = calloc(1,
sizeof(**TitleScreens[j]->Labels));
+ lua_pushnil(l);
+ while (lua_next(l, -2)) {
+ value = LuaToString(l, -2);
+ if (!strcmp(value, "Text")) {
+
TitleScreens[j]->Labels[k]->Text = strdup(LuaToString(l, -1));
+ } else if (!strcmp(value,
"Font")) {
+
TitleScreens[j]->Labels[k]->Font = CclFontByIdentifier(LuaToString(l, -1));
+ } else if (!strcmp(value,
"Pos")) {
+ if (!lua_istable(l, -1)
|| luaL_getn(l, -1) != 2) {
+
lua_pushstring(l, "incorrect argument");
+ lua_error(l);
+ }
+ lua_rawgeti(l, -1, 1);
+
TitleScreens[j]->Labels[k]->Xofs = LuaToNumber(l, -1);
+ lua_pop(l, 1);
+ lua_rawgeti(l, -1, 2);
+
TitleScreens[j]->Labels[k]->Yofs = LuaToNumber(l, -1);
+ lua_pop(l, 1);
+ } else if (!strcmp(value,
"Flags")) {
+ int subsubargs;
+ int subk;
+
+ if (!lua_istable(l,
-1)) {
+
lua_pushstring(l, "incorrect argument");
+ lua_error(l);
+ }
+ subsubargs =
luaL_getn(l, -1);
+ for (subk = 0; subk <
subsubargs; ++subk) {
+ lua_rawgeti(l,
-1, subk + 1);
+ value =
LuaToString(l, -1);
+ lua_pop(l, 1);
+ if
(!strcmp(value, "center")) {
+
TitleScreens[j]->Labels[k]->Flags |= TitleFlagCenter;
+ } else {
+
lua_pushstring(l, "incorrect flag");
+
lua_error(l);
+ }
+ }
} else {
- lua_pushstring(l,
"incorrect flag");
+ lua_pushfstring(l,
"Unsupported key: %s", value);
lua_error(l);
}
lua_pop(l, 1);
}
+ lua_pop(l, 1);
}
- lua_pop(l, 1);
- lua_pop(l, 1);
- ++j;
+ } else {
+ lua_pushfstring(l, "Unsupported key: %s",
value);
+ lua_error(l);
}
+ lua_pop(l, 1);
}
- lua_pop(l, 1);
}
return 0;
@@ -5804,7 +5809,7 @@
lua_error(l);
}
item->mitype = MI_TYPE_VSLIDER;
- item->d.vslider.defper = -1;
+ item->d.vslider.defper = -1;
subargs = luaL_getn(l, j + 1);
for (k = 0; k < subargs; ++k) {
@@ -6100,7 +6105,7 @@
lua_error(l);
}
item->mitype = MI_TYPE_HSLIDER;
- item->d.hslider.defper = -1;
+ item->d.hslider.defper = -1;
subargs = luaL_getn(l, j + 1);
for (k = 0; k < subargs; ++k) {
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Stratagus-CVS] stratagus/src include/stratagus.h stratagus/str...,
address@hidden <=