stratagus-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Stratagus-CVS] stratagus data/ccl/stratagus.ccl doc/ChangeLog....


From: address@hidden
Subject: [Stratagus-CVS] stratagus data/ccl/stratagus.ccl doc/ChangeLog....
Date: 22 Dec 2003 19:01:30 +1100

CVSROOT:        /home/strat
Module name:    stratagus
Changes by:      <address@hidden>       03/12/22 19:01:29

Modified files:
        data/ccl       : stratagus.ccl 
        doc            : ChangeLog.html 
        doc/ccl        : config.html 
        src/include    : stratagus.h 
        src/stratagus  : stratagus.c 
        src/ui         : ccl_ui.c ui.c 

Log message:
        Added Text strings support to Title Screen (from Carlos Perelló Marín)

Patches:
Index: stratagus/data/ccl/stratagus.ccl
diff -u stratagus/data/ccl/stratagus.ccl:1.30 
stratagus/data/ccl/stratagus.ccl:1.31
--- stratagus/data/ccl/stratagus.ccl:1.30       Thu Dec 11 17:37:54 2003
+++ stratagus/data/ccl/stratagus.ccl    Mon Dec 22 19:01:24 2003
@@ -26,7 +26,7 @@
 ;;      along with this program; if not, write to the Free Software
 ;;      Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  
USA
 ;;
-;;     $Id: stratagus.ccl,v 1.30 2003/12/11 06:37:54 wizzard Exp $
+;;     $Id: stratagus.ccl,v 1.31 2003/12/22 08:01:24 wizzard Exp $
 
 ;; For documentation see stratagus/doc/ccl/ccl.html
 
@@ -56,8 +56,8 @@
 
 ;;     Enter your default title screen.
 (set-title-screens!
-  '("graphics/ui/stratagus.png" "music/default.mod")
-;  '("graphics/logo_stratagus.avi")
+  '(image "graphics/ui/stratagus.png" music "music/default.mod"
+;  '(image "graphics/logo_stratagus.avi")
 )
 
 ;;     Enter your default menu background.
Index: stratagus/doc/ChangeLog.html
diff -u stratagus/doc/ChangeLog.html:1.590 stratagus/doc/ChangeLog.html:1.591
--- stratagus/doc/ChangeLog.html:1.590  Thu Dec 11 17:37:54 2003
+++ stratagus/doc/ChangeLog.html        Mon Dec 22 19:01:24 2003
@@ -2,7 +2,7 @@
 <html>
 <head>
 <!--
-----   $Id: ChangeLog.html,v 1.590 2003/12/11 06:37:54 wizzard Exp $
+----   $Id: ChangeLog.html,v 1.591 2003/12/22 08:01:24 wizzard Exp $
 
 ----   (c) Copyright 1998-2003 by Lutz Sammer
 
@@ -36,6 +36,7 @@
 <li>Future 2.00 Release<p>
     <ul>
     <li>++
+    <li>Added Text strings support to Title Screen (from Carlos Perelló Marín).
     <li>Splash Damage Configurable (from Russell Smith).
     <li>Fixed Bug #6924: missile cast near map border (from Russell Smith).
     <li>Rewrote video using SDL_Surface, enable with -DUSE_SDL_SURFACE (from 
Nehal Mistry).
Index: stratagus/doc/ccl/config.html
diff -u stratagus/doc/ccl/config.html:1.36 stratagus/doc/ccl/config.html:1.37
--- stratagus/doc/ccl/config.html:1.36  Sat Nov 29 21:28:04 2003
+++ stratagus/doc/ccl/config.html       Mon Dec 22 19:01:25 2003
@@ -1339,10 +1339,11 @@
 <a href="../../data/ccl/stratagus.ccl"> $LIBARYPATH/ccl/stratagus.ccl </a>
 
 <a name="set-title-screens!"></a>
-<h3>(set-title-screens! (image music) ...)</h3>
-
-Change the default title screens.
+<h3>(set-title-screens! '(tag1 value1 tag2 value ...) ...)</h3>
 
+Change the default title screens.<br>
+<br>
+Possible tags:
 
 <dl>
 <dt>image</dt>
@@ -1353,6 +1354,22 @@
 <dd>Optional music to be played with the image or video.  Use "none" to stop
 previously playing music.
 </dd>
+<dt>timeout</dt>
+<dd>The number of seconds we should show this title-screen.</dd>
+<dt>label</dt>
+<dd>Optional text to be displayed. It's a list of elements with three tags:
+<dl>
+<dt>text</dt>
+<dd>The text string to render
+</dd>
+<dt>pos</dt>
+<dd>The text coords to render
+</dd>
+<dt>flags</dt>
+<dd>The flags that tell us how should be interpretated the pos coords. 
Possible values is center
+</dd>
+</dl>
+</dd>
 </dl>
 
 <h4>Example</h4>
@@ -1360,7 +1377,11 @@
 <pre>
     ;; This is the default title displayed.
     (set-title-screens!
-      '("graphics/ui/stratagus.png" "music/default.mod"))
+      '(image "graphics/ui/title.png"
+        music "music/title.wav.gz"
+        label
+         ((text "~white~Copyright © 1998-2003 The Stratagus Project. All 
rights reserved."
+           pos (0 45) flags (bottom center)))))
 </pre>
 
 <h4>Used</h4>
@@ -1555,7 +1576,7 @@
 <a href="../../data/ccl/stratagus.ccl"> ~/.stratagus/preferences1.ccl </a>
 
 <hr>
-Last changed: $Id: config.html,v 1.36 2003/11/29 10:28:04 pludov Exp $<br>
+Last changed: $Id: config.html,v 1.37 2003/12/22 08:01:25 wizzard Exp $<br>
 All trademarks and copyrights on this page are owned by their respective 
owners.
 <address>(c) 2002-2003 by <a href="http://stratagus.org";>
 The Stratagus Project</a></address></body></html>
Index: stratagus/src/include/stratagus.h
diff -u stratagus/src/include/stratagus.h:1.29 
stratagus/src/include/stratagus.h:1.30
--- stratagus/src/include/stratagus.h:1.29      Sat Dec 20 16:33:28 2003
+++ stratagus/src/include/stratagus.h   Mon Dec 22 19:01:26 2003
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: stratagus.h,v 1.29 2003/12/20 05:33:28 jsalmon3 Exp $
+//     $Id: stratagus.h,v 1.30 2003/12/22 08:01:26 wizzard Exp $
 
 #ifndef __STRATAGUS_H__
 #define __STRATAGUS_H__
@@ -444,9 +444,23 @@
        */
 #define MyRand()               rand()
 
+enum {
+    TitleFlagCenter    = 1 << 0,       /// Center Text
+    TitleFlagBlink     = 1 << 1,       /// Blinking Text (FIXME: Implement it.)
+};
+
+typedef struct _title_screen_label_ {
+    char* Text;
+    int xofs;
+    int yofs;
+    int flags;
+} TitleScreenLabel;
+
 typedef struct _title_screen_ {
        char* File;
        char* Music;
+       int Timeout;
+       TitleScreenLabel** Labels;
 } TitleScreen;
 extern TitleScreen** TitleScreens;             /// File for title screen
 extern char* GameName;                                         /// Name of the 
game (wc2,wc1)
Index: stratagus/src/stratagus/stratagus.c
diff -u stratagus/src/stratagus/stratagus.c:1.237 
stratagus/src/stratagus/stratagus.c:1.238
--- stratagus/src/stratagus/stratagus.c:1.237   Mon Dec 22 18:52:11 2003
+++ stratagus/src/stratagus/stratagus.c Mon Dec 22 19:01:27 2003
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: stratagus.c,v 1.237 2003/12/22 07:52:11 wizzard Exp $
+//     $Id: stratagus.c,v 1.238 2003/12/22 08:01:27 wizzard Exp $
 
 //@{
 
@@ -1293,6 +1293,10 @@
        char** argv __attribute__ ((unused)))
 {
        int i;
+       int j;
+       int x;
+       int y;
+       float ratio;
 
        PrintHeader();
        printf(
@@ -1323,6 +1327,8 @@
        //
        //              Show title screen.
        //
+       SetDefaultTextColors(FontYellow, FontWhite);
+       LoadFonts();
        SetClipping(0, 0, VideoWidth - 1, VideoHeight - 1);
        if (TitleScreens) {
                for (i = 0; TitleScreens[i]; ++i) {
@@ -1335,9 +1341,39 @@
                        if (PlayMovie(TitleScreens[i]->File,
                                        PlayMovieZoomScreen | 
PlayMovieKeepAspect)) {
                                DisplayPicture(TitleScreens[i]->File);
+                               if (TitleScreens[i]->Labels) {
+                                       if (VideoDepth && 
IsFontLoaded(SmallFont) &&
+                                               IsFontLoaded(GameFont) && 
IsFontLoaded(LargeFont)) {
+#ifndef USE_SDL_SURFACE
+                                               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);
+                                                       }
+                                               }
+#ifndef USE_SDL_SURFACE
+                                               VideoUnlockScreen();
+#endif
+                                       }
+                               }
                                Invalidate();
-                               // FIXME: make the time configurable
-                               WaitForInput(20);
+                               WaitForInput(TitleScreens[i]->Timeout);
                        }
                }
        }
Index: stratagus/src/ui/ccl_ui.c
diff -u stratagus/src/ui/ccl_ui.c:1.173 stratagus/src/ui/ccl_ui.c:1.174
--- stratagus/src/ui/ccl_ui.c:1.173     Sat Dec 20 16:33:39 2003
+++ stratagus/src/ui/ccl_ui.c   Mon Dec 22 19:01:28 2003
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: ccl_ui.c,v 1.173 2003/12/20 05:33:39 jsalmon3 Exp $
+//     $Id: ccl_ui.c,v 1.174 2003/12/22 08:01:28 wizzard Exp $
 
 //@{
 
@@ -535,12 +535,25 @@
 local SCM CclSetTitleScreens(SCM list)
 {
        int i;
+       int j;
        SCM value;
+       SCM labelvalue;
+       SCM labellist;
+       SCM poslist;
+       SCM flagslist;
+       char* s1;
 
        if (TitleScreens) {
                for (i = 0; TitleScreens[i]; ++i) {
                        free(TitleScreens[i]->File);
                        free(TitleScreens[i]->Music);
+                       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);
+                       }
                        free(TitleScreens[i]);
                }
                free(TitleScreens);
@@ -553,27 +566,102 @@
                        value = gh_car(list);
                        list = gh_cdr(list);
                        TitleScreens[i] = calloc(1, sizeof(**TitleScreens));
+                       TitleScreens[i]->Timeout = 20; // Default timeout
+                       while (!gh_null_p(value)) {
+                               if (gh_eq_p(gh_car(value), 
gh_symbol2scm("image"))) {
+                                       value = gh_cdr(value);
                        TitleScreens[i]->File = gh_scm2newstr(gh_car(value), 
NULL);
                        value = gh_cdr(value);
-                       if (!gh_null_p(value)) {
+                               } else if (gh_eq_p(gh_car(value), 
gh_symbol2scm("music"))) {
+                                       value = gh_cdr(value);
                                TitleScreens[i]->Music = 
gh_scm2newstr(gh_car(value), NULL);
+                                       value = gh_cdr(value);
+                               } else if (gh_eq_p(gh_car(value), 
gh_symbol2scm("timeout"))) {
+                                       value = gh_cdr(value);
+                                       TitleScreens[i]->Timeout = 
gh_scm2int(gh_car(value));
+                                       value = gh_cdr(value);
+                               } else if (gh_eq_p(gh_car(value), 
gh_symbol2scm("label"))) {
+                                       value = gh_cdr(value);
+                                       labellist = gh_car (value);
+                                       value = gh_cdr (value);
+
+                                       j = 0;
+                                       TitleScreens[i]->Labels = 
calloc(gh_length(labellist) + 1, sizeof(*TitleScreens[i]->Labels));
+                                       while (!gh_null_p(labellist)) {
+                                               labelvalue = gh_car(labellist);
+                                               labellist = gh_cdr(labellist);
+                                               TitleScreens[i]->Labels[j] = 
calloc(1, sizeof(**TitleScreens[i]->Labels));
+                                               while (!gh_null_p(labelvalue)) {
+                                                       if 
(gh_eq_p(gh_car(labelvalue), gh_symbol2scm("text"))) {
+                                                               labelvalue = 
gh_cdr(labelvalue);
+                                                               
TitleScreens[i]->Labels[j]->Text = gh_scm2newstr(gh_car(labelvalue), NULL);
+                                                               labelvalue = 
gh_cdr(labelvalue);
+                                                       } else if 
(gh_eq_p(gh_car(labelvalue), gh_symbol2scm("pos"))) {
+                                                               labelvalue = 
gh_cdr(labelvalue);
+                                                               poslist = 
gh_car(labelvalue);
+                                                               labelvalue = 
gh_cdr(labelvalue);
+                                                               
TitleScreens[i]->Labels[j]->xofs = gh_scm2int(gh_car(poslist));
+                                                               poslist = 
gh_cdr(poslist);
+                                                               
TitleScreens[i]->Labels[j]->yofs = gh_scm2int(gh_car(poslist));
+                                                       } else if 
(gh_eq_p(gh_car(labelvalue), gh_symbol2scm("flags"))) {
+                                                               labelvalue = 
gh_cdr(labelvalue);
+                                                               flagslist = 
gh_car(labelvalue);
+                                                               labelvalue = 
gh_cdr(labelvalue);
+                                                               while 
(!gh_null_p(flagslist)) {
+                                                                       if 
(gh_eq_p(gh_car(flagslist), gh_symbol2scm("center"))) {
+                                                                               
TitleScreens[i]->Labels[j]->flags |= TitleFlagCenter;
+                                                                               
flagslist = gh_cdr(flagslist);
+                                                                       } else {
+                                                                               
s1 = gh_scm2newstr(gh_car(flagslist), NULL);
+                                                                               
fprintf(stderr, "Unsupported flag %s\n", s1);
+                                                                               
free(s1);
+                                                                               
flagslist = gh_cdr(flagslist);
+                                                                       }
+                                                               }
+                                                       } else {
+                                                               s1 = 
gh_scm2newstr(gh_car(labelvalue), NULL);
+                                                               fprintf(stderr, 
"Unsupported tag %s\n", s1);
+                                                               free(s1);
+                                                               labelvalue = 
gh_cdr(labelvalue);
+                                                       }
+                                               }
+                                               ++j;
+                                       }
+                               } else {
+                                       s1 = gh_scm2newstr(gh_car(value), NULL);
+                                       fprintf(stderr, "Unsupported tag %s\n", 
s1);
+                                       free(s1);
+                                       value = gh_cdr(value);
+                               }
                        }
                        ++i;
                }
        }
        return SCM_UNSPECIFIED;
+
 }
 #elif defined(USE_LUA)
 local int CclSetTitleScreens(lua_State* l)
 {
        int i;
+       int j;
+       int k;
        int tables;
        int args;
+       int subargs;
+       int narg;
 
        if (TitleScreens) {
                for (i = 0; TitleScreens[i]; ++i) {
                        free(TitleScreens[i]->File);
                        free(TitleScreens[i]->Music);
+                       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);
+                       }
                        free(TitleScreens[i]);
                }
                free(TitleScreens);
@@ -584,20 +672,85 @@
        TitleScreens = calloc(tables + 1, sizeof(*TitleScreens));
 
        for (i = 0; i < tables; ++i) {
-               args = luaL_getn(l, i + 1);
-               if (!lua_istable(l, i + 1) || (args != 1 && args != 2)) {
+               if (!lua_istable(l, i + 1)) {
                        lua_pushstring(l, "incorrect argument");
                        lua_error(l);
                }
                TitleScreens[i] = calloc(1, sizeof(**TitleScreens));
-               lua_rawgeti(l, i + 1, 1);
+               lua_pushstring(l, "Image");
+               lua_gettable(l, i + 1);
                TitleScreens[i]->File = strdup(LuaToString(l, -1));
                lua_pop(l, 1);
-               if (args == 2) {
-                       lua_rawgeti(l, i + 1, 2);
+               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)) {
+                                       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;
+                                               } else {
+                                                       lua_pushstring(l, 
"incorrect flag");
+                                                       lua_error(l);
+                                               }
+                                               lua_pop(l, 1);
+                                       }
+                               }
+                               lua_pop(l, 1);
+                               lua_pop(l, 1);
+                               ++j;
+                       }
+               }
+               lua_pop(l, 1);
        }
 
        return 0;
Index: stratagus/src/ui/ui.c
diff -u stratagus/src/ui/ui.c:1.91 stratagus/src/ui/ui.c:1.92
--- stratagus/src/ui/ui.c:1.91  Sat Dec 20 16:33:44 2003
+++ stratagus/src/ui/ui.c       Mon Dec 22 19:01:28 2003
@@ -27,7 +27,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: ui.c,v 1.91 2003/12/20 05:33:44 jsalmon3 Exp $
+//     $Id: ui.c,v 1.92 2003/12/22 08:01:28 wizzard Exp $
 
 //@{
 
@@ -657,7 +657,7 @@
        int i;
 
        CLprintf(file, "\n;;; -----------------------------------------\n");
-       CLprintf(file, ";;; MODULE: ui $Id: ui.c,v 1.91 2003/12/20 05:33:44 
jsalmon3 Exp $\n\n");
+       CLprintf(file, ";;; MODULE: ui $Id: ui.c,v 1.92 2003/12/22 08:01:28 
wizzard Exp $\n\n");
 
        // Contrast, Brightness, Saturation
        CLprintf(file, "(set-contrast! %d)\n", TheUI.Contrast);
@@ -786,6 +786,7 @@
 global void CleanUserInterface(void)
 {
        int i;
+       int j;
        MenuPanel* menupanel;
 
        //
@@ -828,6 +829,13 @@
                for (i = 0; TitleScreens[i]; ++i) {
                        free(TitleScreens[i]->File);
                        free(TitleScreens[i]->Music);
+                       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);
+                       }
                        free(TitleScreens[i]);
                }
                free(TitleScreens);




reply via email to

[Prev in Thread] Current Thread [Next in Thread]