[Tux4kids-commits] r1002 - tuxmath/branches/lan/src
akash gangil
gangil-guest at alioth.debian.org
Fri May 29 11:17:00 UTC 2009
Author: gangil-guest
Date: 2009-05-29 11:17:00 +0000 (Fri, 29 May 2009)
New Revision: 1002
Modified:
tuxmath/branches/lan/src/game.c
tuxmath/branches/lan/src/game.h
tuxmath/branches/lan/src/highscore.c
tuxmath/branches/lan/src/highscore.h
tuxmath/branches/lan/src/network.c
tuxmath/branches/lan/src/titlescreen.c
Log:
added the standby window which appears while the server and client wait for connection
Modified: tuxmath/branches/lan/src/game.c
===================================================================
--- tuxmath/branches/lan/src/game.c 2009-05-29 09:06:49 UTC (rev 1001)
+++ tuxmath/branches/lan/src/game.c 2009-05-29 11:17:00 UTC (rev 1002)
@@ -165,7 +165,7 @@
static void game_set_message(game_message *,const char *,int x, int y);
static void game_clear_message(game_message*);
static void game_clear_messages(void);
-static void game_write_message(const game_message* msg);
+void game_write_message(const game_message *msg);
static void game_write_messages(void);
static void draw_led_console(void);
static void draw_question_counter(void);
Modified: tuxmath/branches/lan/src/game.h
===================================================================
--- tuxmath/branches/lan/src/game.h 2009-05-29 09:06:49 UTC (rev 1001)
+++ tuxmath/branches/lan/src/game.h 2009-05-29 11:17:00 UTC (rev 1002)
@@ -138,6 +138,7 @@
};
int game(void);
+
void game_set_start_message(const char*, const char*, const char*, const char*);
/* draw_nums() is used in options.c and factoroids.c/h so need extern linkage */
Modified: tuxmath/branches/lan/src/highscore.c
===================================================================
--- tuxmath/branches/lan/src/highscore.c 2009-05-29 09:06:49 UTC (rev 1001)
+++ tuxmath/branches/lan/src/highscore.c 2009-05-29 11:17:00 UTC (rev 1002)
@@ -353,6 +353,185 @@
NameEntry(pl_name, _("You Are In The Hall of Fame!"), _("Enter Your Name:"));
}
+void Standby(const char* heading, const char* sub)
+{
+
+ SDL_Rect loc;
+ SDL_Rect TuxRect,
+ stopRect;
+
+
+ int finished = 0;
+ int tux_frame = 0;
+ Uint32 frame = 0;
+ Uint32 start = 0;
+
+ const int BG_Y = 100;
+ const int BG_WIDTH = 400;
+ const int BG_HEIGHT = 200;
+
+ sprite* Tux = LoadSprite("tux/bigtux", IMG_ALPHA);
+
+
+
+ /* We need to get Unicode vals from SDL keysyms */
+ SDL_EnableUNICODE(SDL_ENABLE);
+
+
+ /* Draw background: */
+ if (current_bkg())
+ SDL_BlitSurface(current_bkg(), NULL, screen, NULL);
+
+ /* Red "Stop" circle in upper right corner to go back to main menu: */
+ if (images[IMG_STOP])
+ {
+ stopRect.w = images[IMG_STOP]->w;
+ stopRect.h = images[IMG_STOP]->h;
+ stopRect.x = screen->w - images[IMG_STOP]->w;
+ stopRect.y = 0;
+ SDL_BlitSurface(images[IMG_STOP], NULL, screen, &stopRect);
+ }
+
+ if (Tux && Tux->frame[0]) /* make sure sprite has at least one frame */
+ {
+ TuxRect.w = Tux->frame[0]->w;
+ TuxRect.h = Tux->frame[0]->h;
+ TuxRect.x = 0;
+ TuxRect.y = screen->h - Tux->frame[0]->h;
+ }
+
+ /* Draw translucent background for text: */
+ {
+ SDL_Rect bg_rect;
+ bg_rect.x = (screen->w)/2 - BG_WIDTH/2;
+ bg_rect.y = BG_Y;
+ bg_rect.w = BG_WIDTH;
+ bg_rect.h = BG_HEIGHT;
+ DrawButton(&bg_rect, 15, REG_RGBA);
+
+ bg_rect.x += 10;
+ bg_rect.y += 10;
+ bg_rect.w -= 20;
+ bg_rect.h = 180;
+ DrawButton(&bg_rect, 10, SEL_RGBA);
+ }
+
+ /* Draw heading: */
+ {
+ SDL_Surface* s = BlackOutline(_(heading),
+ DEFAULT_MENU_FONT_SIZE, &white);
+ if (s)
+ {
+ loc.x = (screen->w/2) - (s->w/2);
+ loc.y = 150;
+ SDL_BlitSurface(s, NULL, screen, &loc);
+ SDL_FreeSurface(s);
+ }
+
+ s = BlackOutline(_(sub),
+ DEFAULT_MENU_FONT_SIZE, &white);
+ if (s)
+ {
+ loc.x = (screen->w/2) - (s->w/2);
+ loc.y = 170;
+ SDL_BlitSurface(s, NULL, screen, &loc);
+ SDL_FreeSurface(s);
+ }
+ }
+
+ /* and update: */
+ SDL_UpdateRect(screen, 0, 0, 0, 0);
+
+
+
+ while (!finished)
+ {
+ start = SDL_GetTicks();
+
+ while (SDL_PollEvent(&event))
+ {
+ switch (event.type)
+ {
+ case SDL_QUIT:
+ {
+ cleanup();
+ }
+
+ case SDL_MOUSEBUTTONDOWN:
+ /* "Stop" button - go to main menu: */
+ {
+ if (inRect(stopRect, event.button.x, event.button.y ))
+ {
+ finished = 1;
+ playsound(SND_TOCK);
+ break;
+ }
+ }
+ case SDL_KEYDOWN:
+ {
+#ifdef TUXMATH_DEBUG
+ fprintf(stderr, "Before keypress, string is %S\tlength = %d\n",
+ wchar_buf, (int)wcslen(wchar_buf));
+#endif
+ switch (event.key.keysym.sym)
+ {
+ case SDLK_ESCAPE:
+
+ {
+ finished = 1;
+ playsound(SND_TOCK);
+ break;
+ }
+
+ default:
+ continue;
+ /* For any other keys, if the key has a Unicode value, */
+ /* we add it to our string: */
+
+
+ } /* end 'switch (event.key.keysym.sym)' */
+
+
+ /* --- make tux blink --- */
+ switch (frame % TUX6)
+ {
+ case 0: tux_frame = 1; break;
+ case TUX1: tux_frame = 2; break;
+ case TUX2: tux_frame = 3; break;
+ case TUX3: tux_frame = 4; break;
+ case TUX4: tux_frame = 3; break;
+ case TUX5: tux_frame = 2; break;
+ default: tux_frame = 0;
+ }
+
+ if (Tux && tux_frame)
+ {
+ SDL_BlitSurface(Tux->frame[tux_frame - 1], NULL, screen, &TuxRect);
+ SDL_UpdateRect(screen, TuxRect.x, TuxRect.y, TuxRect.w, TuxRect.h);
+ }
+
+ /* Wait so we keep frame rate constant: */
+ while ((SDL_GetTicks() - start) < 33)
+ {
+ SDL_Delay(20);
+ }
+ frame++;
+ }
+}
+}
+} // End of while (!finished) loop
+
+ FreeSprite(Tux);
+
+ /* Turn off SDL Unicode lookup (because has some overhead): */
+ SDL_EnableUNICODE(SDL_DISABLE);
+
+}
+
+
+
+
+
void NameEntry(char* pl_name, const char* heading, const char* sub)
{
char UTF8_buf[HIGH_SCORE_NAME_LENGTH * 3] = {'\0'};
Modified: tuxmath/branches/lan/src/highscore.h
===================================================================
--- tuxmath/branches/lan/src/highscore.h 2009-05-29 09:06:49 UTC (rev 1001)
+++ tuxmath/branches/lan/src/highscore.h 2009-05-29 11:17:00 UTC (rev 1002)
@@ -16,6 +16,7 @@
#include "globals.h"
+void Standby(const char* heading, const char* sub);
void DisplayHighScores(int level);
void HighScoreNameEntry(char* pl_name);
void NameEntry(char* pl_name, const char* heading, const char* sub);
Modified: tuxmath/branches/lan/src/network.c
===================================================================
--- tuxmath/branches/lan/src/network.c 2009-05-29 09:06:49 UTC (rev 1001)
+++ tuxmath/branches/lan/src/network.c 2009-05-29 11:17:00 UTC (rev 1002)
@@ -8,7 +8,9 @@
#include <unistd.h>
#include "SDL.h"
#include "SDL_net.h"
-#include <game.h>
+
+
+
//*** ipaddress of the server and the port would be taken by the user @ the time he selects "LAN multiplayer" from the options menu..
//***also should I fix the port beforehand or ask it from the user...
Modified: tuxmath/branches/lan/src/titlescreen.c
===================================================================
--- tuxmath/branches/lan/src/titlescreen.c 2009-05-29 09:06:49 UTC (rev 1001)
+++ tuxmath/branches/lan/src/titlescreen.c 2009-05-29 11:17:00 UTC (rev 1002)
@@ -42,6 +42,7 @@
#include "highscore.h"
#include "convert_utf.h" // for wide char to UTF-8 conversion
#include "SDL_extras.h"
+
//#include "lan_client.h"
/* --- Data Structure for Dirty Blitting --- */
@@ -883,10 +884,16 @@
NameEntry(port, _("Enter the port number"),
_(""));
+
// lan_client_set_parameter(HOST, host);
// lan_client_set_parameter(PORT, port);
- // if((lan_client_connect(host,port))==0)
- game();
+ // if((lan_client_connect(host,port))==0)
+ Standby(_("No Host...=("),_("Press Esc to go back")); // this function is defined in highscore.c...
+
+
+
+
+ game();
}
}
@@ -933,6 +940,7 @@
else
{NameEntry(port, _("Enter the PORT"),
_(""));
+ Standby(_("Waiting for other player"),_("Press Esc to go back"));
// lan_server_connect(port);
game();}
break;
More information about the Tux4kids-commits
mailing list