From 95343932dcddb20c50b7ad8ea52a903247963c39 Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Fri, 21 Oct 2011 21:11:01 -0400
Subject: [PATCH] Okay, everything compiles now.
---
Makefile.am | 1 +
init.cpp | 35 +++++++++++++++++++----------------
main.cpp | 20 +++++++++-----------
scores.cpp | 8 ++++----
screenlib/SDL_FrameBuf.h | 4 +++-
utils/hashtable.h | 8 ++++++++
6 files changed, 44 insertions(+), 32 deletions(-)
diff --git a/Makefile.am b/Makefile.am
index aacdb8d8..32691048 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -36,6 +36,7 @@ Maelstrom_LDADD = \
$(LOGIC)/liblogic.a \
screenlib/libSDLscreen.a \
maclib/libSDLmac.a \
+ utils/libutils.a \
@MATHLIB@ @INETLIB@ @ICONOBJ@
SUBDIRS = $(LOGIC) screenlib maclib utils
diff --git a/init.cpp b/init.cpp
index 69b1073b..3fe7a931 100644
--- a/init.cpp
+++ b/init.cpp
@@ -65,8 +65,8 @@ void DoSplash(void)
error("Can't load Ambrosia splash title! (ID=%d)\n", 999);
return;
}
- screen->QueueBlit(SCREEN_WIDTH/2-splash->w/2,
- SCREEN_HEIGHT/2-splash->h/2, splash, NOCLIP);
+ screen->QueueBlit(SCREEN_WIDTH/2-screen->GetImageWidth(splash)/2,
+ SCREEN_HEIGHT/2-screen->GetImageHeight(splash)/2, splash, NOCLIP);
screen->Update();
screen->FreeImage(splash);
}
@@ -80,6 +80,7 @@ void DoIntroScreen(void)
SDL_Texture *intro, *text;
Uint16 Yoff, Xoff;
Uint32 clr, ltClr, ltrClr;
+ int introW, introH;
intro = Load_Title(screen, 130);
if ( intro == NULL ) {
@@ -93,17 +94,19 @@ void DoIntroScreen(void)
ltrClr = screen->MapRGB(50000>>8, 50000>>8, 0xFF);
screen->Clear();
- Xoff = (SCREEN_WIDTH-intro->w)/2;
- Yoff = (SCREEN_HEIGHT-intro->h)/2;
- screen->DrawRect(Xoff-1, Yoff-1, intro->w+2, intro->h+2, clr);
- screen->DrawRect(Xoff-2, Yoff-2, intro->w+4, intro->h+4, clr);
- screen->DrawRect(Xoff-3, Yoff-3, intro->w+6, intro->h+6, ltClr);
- screen->DrawRect(Xoff-4, Yoff-4, intro->w+8, intro->h+8, ltClr);
- screen->DrawRect(Xoff-5, Yoff-5, intro->w+10, intro->h+10, ltrClr);
- screen->DrawRect(Xoff-6, Yoff-6, intro->w+12, intro->h+12, ltClr);
- screen->DrawRect(Xoff-7, Yoff-7, intro->w+14, intro->h+14, clr);
- Yoff += intro->h;
- screen->QueueBlit(SCREEN_WIDTH/2-intro->w/2, SCREEN_HEIGHT/2-intro->h/2,
+ introW = screen->GetImageWidth(intro);
+ introH = screen->GetImageHeight(intro);
+ Xoff = (SCREEN_WIDTH-introW)/2;
+ Yoff = (SCREEN_HEIGHT-introH)/2;
+ screen->DrawRect(Xoff-1, Yoff-1, introW+2, introH+2, clr);
+ screen->DrawRect(Xoff-2, Yoff-2, introW+4, introH+4, clr);
+ screen->DrawRect(Xoff-3, Yoff-3, introW+6, introH+6, ltClr);
+ screen->DrawRect(Xoff-4, Yoff-4, introW+8, introH+8, ltClr);
+ screen->DrawRect(Xoff-5, Yoff-5, introW+10, introH+10, ltrClr);
+ screen->DrawRect(Xoff-6, Yoff-6, introW+12, introH+12, ltClr);
+ screen->DrawRect(Xoff-7, Yoff-7, introW+14, introH+14, clr);
+ Yoff += introH;
+ screen->QueueBlit(SCREEN_WIDTH/2-introW/2, SCREEN_HEIGHT/2-introH/2,
intro, NOCLIP);
screen->FreeImage(intro);
@@ -117,8 +120,8 @@ void DoIntroScreen(void)
text = fontserv->TextImage("Loading...", geneva, STYLE_BOLD,
0xFF, 0xFF, 0x00);
if ( text ) {
- screen->QueueBlit(SCREEN_WIDTH/2-text->w/2,
- Yoff+20-text->h/2, text, NOCLIP);
+ screen->QueueBlit(SCREEN_WIDTH/2-screen->GetImageWidth(text)/2,
+ Yoff+20-screen->GetImageHeight(text)/2, text, NOCLIP);
fontserv->FreeText(text);
}
fontserv->FreeFont(geneva);
@@ -750,7 +753,7 @@ int DoInitializations(Uint32 video_flags)
#endif
/* Load the Font Server */
- fontserv = new FontServ("Maelstrom Fonts");
+ fontserv = new FontServ(screen, "Maelstrom Fonts");
if ( fontserv->Error() ) {
error("Fatal: %s\n", fontserv->Error());
return(-1);
diff --git a/main.cpp b/main.cpp
index 0955e4d2..c5b2cf9c 100644
--- a/main.cpp
+++ b/main.cpp
@@ -429,15 +429,15 @@ int main(int argc, char *argv[])
int DrawText(int x, int y, const char *text, MFont *font, Uint8 style,
Uint8 R, Uint8 G, Uint8 B)
{
- SDL_Surface *textimage;
+ SDL_Texture *textimage;
int width;
textimage = fontserv->TextImage(text, font, style, R, G, B);
if ( textimage == NULL ) {
width = 0;
} else {
- screen->QueueBlit(x, y-textimage->h+2, textimage, NOCLIP);
- width = textimage->w;
+ screen->QueueBlit(x, y-screen->GetImageHeight(textimage)+2, textimage, NOCLIP);
+ width = screen->GetImageWidth(textimage);
fontserv->FreeText(textimage);
}
return(width);
@@ -471,7 +471,7 @@ static void DrawSoundLevel(void)
void DrawMainScreen(void)
{
- SDL_Surface *title;
+ SDL_Texture *title;
MFont *font, *bigfont;
MPoint pt;
Uint16 width, height;
@@ -499,7 +499,6 @@ void DrawMainScreen(void)
ltClr = screen->MapRGB(40000>>8, 40000>>8, 0xFF);
ltrClr = screen->MapRGB(50000>>8, 50000>>8, 0xFF);
- screen->Lock();
screen->Clear();
/* -- Draw the screen frame */
screen->DrawRect(xOff-1, yOff-1, width+2, height+2, clr);
@@ -510,13 +509,12 @@ void DrawMainScreen(void)
screen->DrawRect(xOff-6, yOff-6, width+12, height+12, ltClr);
screen->DrawRect(xOff-7, yOff-7, width+14, height+14, clr);
/* -- Draw the dividers */
- botDiv = yOff + 5 + title->h + 5;
- rightDiv = xOff + 5 + title->w + 5;
+ botDiv = yOff + 5 + screen->GetImageHeight(title) + 5;
+ rightDiv = xOff + 5 + screen->GetImageWidth(title) + 5;
screen->DrawLine(rightDiv, yOff, rightDiv, yOff+height, ltClr);
screen->DrawLine(xOff, botDiv, rightDiv, botDiv, ltClr);
screen->DrawLine(rightDiv, 263+yOff, xOff+width, 263+yOff, ltClr);
/* -- Draw the title image */
- screen->Unlock();
screen->QueueBlit(xOff+5, yOff+5, title, NOCLIP);
screen->Update();
screen->FreeImage(title);
@@ -613,7 +611,7 @@ void DrawMainScreen(void)
error("Can't use Geneva font! -- Exiting.\n");
exit(255);
}
- DrawText(pt.h+gKeyIcon->w+3, pt.v+19, "-",
+ DrawText(pt.h+screen->GetImageWidth(gKeyIcon)+3, pt.v+19, "-",
font, STYLE_NORM, 0xFF, 0xFF, 0x00);
pt.h = rightDiv + 50;
@@ -657,11 +655,11 @@ static void DrawKey(MPoint *pt, const char *key, const char *text, void (*callba
DrawText(pt->h+14, pt->v+20, key, geneva, STYLE_BOLD, 0xFF, 0xFF, 0xFF);
DrawText(pt->h+13, pt->v+19, key, geneva, STYLE_BOLD, 0x00, 0x00, 0x00);
- DrawText(pt->h+gKeyIcon->w+3, pt->v+19, text,
+ DrawText(pt->h+screen->GetImageWidth(gKeyIcon)+3, pt->v+19, text,
geneva, STYLE_BOLD, 0xFF, 0xFF, 0x00);
fontserv->FreeFont(geneva);
- buttons.Add_Button(pt->h, pt->v, gKeyIcon->w, gKeyIcon->h, callback);
+ buttons.Add_Button(pt->h, pt->v, screen->GetImageWidth(gKeyIcon), screen->GetImageHeight(gKeyIcon), callback);
} /* -- DrawKey */
diff --git a/scores.cpp b/scores.cpp
index 41e5456c..4108e686 100644
--- a/scores.cpp
+++ b/scores.cpp
@@ -217,10 +217,10 @@ int GetStartLevel(void)
screen);
x = y = 14;
dialog->Add_Image(splash, x, y);
- x += (splash->w+14);
+ x += (screen->GetImageWidth(splash)+14);
text1 = fontserv->TextImage(Ltext1,chicago,STYLE_NORM,0x00,0x00,0x00);
dialog->Add_Image(text1, x, y);
- y += (text1->h+2);
+ y += (screen->GetImageHeight(text1)+2);
text2 = fontserv->TextImage(Ltext2, chicago, STYLE_NORM,
0x00, 0x00, 0x00);
dialog->Add_Image(text2, x, y);
@@ -234,10 +234,10 @@ int GetStartLevel(void)
numeric_entry = new Mac_NumericEntry(X, Y, chicago, fontserv);
numeric_entry->Add_Entry(78, 60, 3, 1, &startlevel);
text3 = fontserv->TextImage(Ltext3,chicago,STYLE_NORM,0x00,0x00,0x00);
- dialog->Add_Image(text3, 78-text3->w-2, 60+3);
+ dialog->Add_Image(text3, 78-screen->GetImageWidth(text3)-2, 60+3);
numeric_entry->Add_Entry(78, 86, 3, 0, &startlives);
text4 = fontserv->TextImage(Ltext4,chicago,STYLE_NORM,0x00,0x00,0x00);
- dialog->Add_Image(text4, 78-text3->w-2, 86+3);
+ dialog->Add_Image(text4, 78-screen->GetImageWidth(text3)-2, 86+3);
dialog->Add_Dialog(numeric_entry);
checkbox = new Mac_CheckBox(&turbofunk, 136, 64, turbotext,
chicago, fontserv);
diff --git a/screenlib/SDL_FrameBuf.h b/screenlib/SDL_FrameBuf.h
index 41f7fc45..007769c7 100644
--- a/screenlib/SDL_FrameBuf.h
+++ b/screenlib/SDL_FrameBuf.h
@@ -58,7 +58,9 @@ class FrameBuf {
return (0xFF0000 | ((Uint32)R << 16) | ((Uint32)G << 8) | B);
}
/* Set the blit clipping rectangle */
- void ClipBlit(SDL_Rect *cliprect);
+ void ClipBlit(SDL_Rect *cliprect) {
+ clip = *cliprect;
+ }
/* Event Routines */
int PollEvent(SDL_Event *event) {
diff --git a/utils/hashtable.h b/utils/hashtable.h
index e11b28c9..6acae01f 100644
--- a/utils/hashtable.h
+++ b/utils/hashtable.h
@@ -19,6 +19,10 @@
#ifndef _hashtable_h
#define _hashtable_h
+#ifdef __cplusplus
+extern "C" {
+#endif
+
// Hashtables...
typedef struct HashTable HashTable;
@@ -37,4 +41,8 @@ int hash_find(const HashTable *table, const void *key, const void **_value);
unsigned hash_hash_string(const void *sym, void *unused);
int hash_keymatch_string(const void *a, const void *b, void *unused);
+#ifdef __cplusplus
+}
+#endif
+
#endif // _hashtable_h