From: Brad A. <br...@us...> - 2012-09-18 16:59:39
|
gemrb: Infinity Engine emulator The branch master has been updated via 7f6288dbd6c82d21467c8f7212437557d6d4d674 (commit) via 04a147f89ea943f9bf1717db1189f570a2db6bf8 (commit) via 037993ffa1c217b3774a382b360b552cfe56419c (commit) via 220b9ab1e5582fe1f82531de5fa966c93acf1555 (commit) via d44cc4da225ac07d8a47d7e6f1ea6105175e97d2 (commit) via 8ce38041f350337988d97581dfeb23edaabbe1e5 (commit) via 4c4c461cc2b79f02207ca56d2706e5fd40f56d19 (commit) via ffbc9e1c821986b68e42bd294052af2d28f5e025 (commit) Summary of changes: gemrb/GUIScripts/GUICommonWindows.py | 59 +++++++++++++++---------- gemrb/core/Font.cpp | 30 ++++++------- gemrb/core/Font.h | 2 + gemrb/core/GUI/Button.cpp | 36 ++++++++++------ gemrb/plugins/BAMImporter/BAMFontManager.cpp | 1 + gemrb/plugins/TTFImporter/TTFFontManager.cpp | 5 +- 6 files changed, 77 insertions(+), 56 deletions(-) from a6d33a2fe76271247fe09e3a5b8a11d696bd1111 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://gemrb.git.sourceforge.net/git/gitweb.cgi?p=gemrb/gemrb;a=commitdiff;h=7f6288dbd6c82d21467c8f7212437557d6d4d674 commit 7f6288dbd6c82d21467c8f7212437557d6d4d674 Merge: 04a147f a6d33a2 Author: Brad Allred <bra...@me...> Date: Tue Sep 18 10:59:16 2012 -0600 Merge branch 'master' of ssh://gemrb.git.sourceforge.net/gitroot/gemrb/gemrb http://gemrb.git.sourceforge.net/git/gitweb.cgi?p=gemrb/gemrb;a=commitdiff;h=04a147f89ea943f9bf1717db1189f570a2db6bf8 commit 04a147f89ea943f9bf1717db1189f570a2db6bf8 Author: Brad Allred <bra...@me...> Date: Mon Sep 17 20:59:26 2012 -0600 Fonts: normalize all font types to the same baseline in original data numeric fonts and text font have different Y offsets. diff --git a/gemrb/plugins/BAMImporter/BAMFontManager.cpp b/gemrb/plugins/BAMImporter/BAMFontManager.cpp index 5bee8cc..f1baa5f 100644 --- a/gemrb/plugins/BAMImporter/BAMFontManager.cpp +++ b/gemrb/plugins/BAMImporter/BAMFontManager.cpp @@ -90,6 +90,7 @@ Font* BAMFontManager::GetFont(ieWord FirstChar, } } else { glyphs[i - glyphIndexOffset] = af->GetFrameWithoutCycle(i); + glyphs[i - glyphIndexOffset]->YPos = 13 - glyphs[i - glyphIndexOffset]->Height; } } diff --git a/gemrb/plugins/TTFImporter/TTFFontManager.cpp b/gemrb/plugins/TTFImporter/TTFFontManager.cpp index 9046c62..8b029f3 100644 --- a/gemrb/plugins/TTFImporter/TTFFontManager.cpp +++ b/gemrb/plugins/TTFImporter/TTFFontManager.cpp @@ -330,9 +330,8 @@ Font* TTFFontManager::GetFont(ieWord FirstChar, // TODO: do an underline if requested glyphs[ch - FirstChar] = core->GetVideoDriver()->CreateSprite8(sprWidth, sprHeight, 8, pixels, pal->col, true, 0); - // FIXME: figure out why this 10 is required and find how to dynamically determine - // presumably this value should change with font size. - glyphs[ch - FirstChar]->YPos = 10 - yoffset; + // for some reason BAM fonts are all based of a YPos of 13 + glyphs[ch - FirstChar]->YPos = 13 - yoffset; } Font* font = new Font(glyphs, FirstChar, LastChar, pal); font->ptSize = ptSize; http://gemrb.git.sourceforge.net/git/gitweb.cgi?p=gemrb/gemrb;a=commitdiff;h=037993ffa1c217b3774a382b360b552cfe56419c commit 037993ffa1c217b3774a382b360b552cfe56419c Author: Brad Allred <bra...@me...> Date: Mon Sep 17 19:33:28 2012 -0600 Button: constrain status icons to the portrait image bounds. diff --git a/gemrb/core/GUI/Button.cpp b/gemrb/core/GUI/Button.cpp index 618089c..ef988bf 100644 --- a/gemrb/core/GUI/Button.cpp +++ b/gemrb/core/GUI/Button.cpp @@ -315,9 +315,18 @@ void Button::Draw(unsigned short x, unsigned short y) if (! (Flags & IE_GUI_BUTTON_MULTILINE)) { align |= IE_FONT_SINGLE_LINE; } - font->Print( Region( x + XPos, y + YPos, Width - 2, Height - 2), - ( unsigned char * ) Text, ppoi, - (ieByte) align, true ); + + Region r; + if (Picture && (Flags & IE_GUI_BUTTON_PORTRAIT) == IE_GUI_BUTTON_PORTRAIT) { + // constrain the label (status icons) to the picture bounds + // we are subtracting IE_FONT_PADDING because Font indents 5px, but we dont want that here + r = Region(picXPos - IE_FONT_PADDING, picYPos + IE_FONT_PADDING, + Picture->Width + IE_FONT_PADDING, Picture->Height); + } else { + r = Region( x + XPos, y + YPos, Width - 2, Height - 2); + } + + font->Print( r, ( unsigned char * ) Text, ppoi, (ieByte) align, true ); } if (! (Flags&IE_GUI_BUTTON_NO_IMAGE)) { http://gemrb.git.sourceforge.net/git/gitweb.cgi?p=gemrb/gemrb;a=commitdiff;h=220b9ab1e5582fe1f82531de5fa966c93acf1555 commit 220b9ab1e5582fe1f82531de5fa966c93acf1555 Author: Brad Allred <bra...@me...> Date: Mon Sep 17 19:30:45 2012 -0600 StatusIcons: refactor icon printing we need 4 columns in IWD2 and the order was all wrong diff --git a/gemrb/GUIScripts/GUICommonWindows.py b/gemrb/GUIScripts/GUICommonWindows.py index a7ab0fc..026af07 100644 --- a/gemrb/GUIScripts/GUICommonWindows.py +++ b/gemrb/GUIScripts/GUICommonWindows.py @@ -1176,17 +1176,6 @@ def UpdatePortraitWindow (): Button.SetPicture (pic, "NOPORTSM") ratio_str, color = GUICommon.SetupDamageInfo (portid+1, Button, Window) - #add effects on the portrait - effects = GemRB.GetPlayerStates (portid+1) - - states = "" - for col in range(len(effects)): - states = effects[col:col+1] + states - if col % 3 == 2: states = "\n" + states - for x in range(3 - (len(effects)/3)): - states = "\n" + states - states = "\n" + states - # character - 1 == bam cycle # blank space if GUICommon.GameIsBG2(): @@ -1216,6 +1205,23 @@ def UpdatePortraitWindow (): HPLabel = Window.GetControl (100+portid) HPLabel.SetText (ratio_str) # TODO: color depending on the ratio HPLabel.SetTextColor (*color) + + #add effects on the portrait + effects = GemRB.GetPlayerStates (portid+1) + + numCols = 4 if GUICommon.GameIsIWD2() else 3 + numEffects = len(effects) + + states = "" + # calculate the partial row + idx = numEffects % numCols + states = effects[0:idx] + "\n" + + for x in range(idx, numEffects): # now do any rows that are full + states = states + effects[x] + if (x - idx) % numCols == numCols - 1: + states = states + "\n" + if flag <> blank: FlagLabel = Window.GetControl(200 + portid) FlagLabel.SetText(flag) http://gemrb.git.sourceforge.net/git/gitweb.cgi?p=gemrb/gemrb;a=commitdiff;h=d44cc4da225ac07d8a47d7e6f1ea6105175e97d2 commit d44cc4da225ac07d8a47d7e6f1ea6105175e97d2 Author: Brad Allred <bra...@me...> Date: Mon Sep 17 19:09:29 2012 -0600 StatusIcons: bottom align status icons for all games diff --git a/gemrb/GUIScripts/GUICommonWindows.py b/gemrb/GUIScripts/GUICommonWindows.py index 4cdc333..a7ab0fc 100644 --- a/gemrb/GUIScripts/GUICommonWindows.py +++ b/gemrb/GUIScripts/GUICommonWindows.py @@ -1164,14 +1164,12 @@ def UpdatePortraitWindow (): Button.SetTooltip ("") continue - portraitFlags = IE_GUI_BUTTON_PICTURE| IE_GUI_BUTTON_HORIZONTAL| \ - IE_GUI_BUTTON_ALIGN_LEFT| IE_GUI_BUTTON_DRAGGABLE|IE_GUI_BUTTON_MULTILINE + portraitFlags = IE_GUI_BUTTON_PICTURE | IE_GUI_BUTTON_HORIZONTAL | IE_GUI_BUTTON_ALIGN_LEFT | \ + IE_GUI_BUTTON_DRAGGABLE | IE_GUI_BUTTON_MULTILINE | IE_GUI_BUTTON_ALIGN_BOTTOM if GUICommon.GameIsIWD2(): - portraitFlags |= IE_GUI_BUTTON_ALIGN_BOTTOM Button.SetEvent (IE_GUI_BUTTON_ON_RIGHT_PRESS, GUIINV.OpenInventoryWindowClick) Button.SetEvent (IE_GUI_BUTTON_ON_PRESS, PortraitButtonOnPress) - else: - portraitFlags |= IE_GUI_BUTTON_ALIGN_TOP + Button.SetFlags (portraitFlags, OP_SET) Button.SetState (IE_GUI_BUTTON_LOCKED) http://gemrb.git.sourceforge.net/git/gitweb.cgi?p=gemrb/gemrb;a=commitdiff;h=8ce38041f350337988d97581dfeb23edaabbe1e5 commit 8ce38041f350337988d97581dfeb23edaabbe1e5 Author: Brad Allred <bra...@me...> Date: Mon Sep 17 19:07:54 2012 -0600 StatusIcons: add a separate label for the top row of flags diff --git a/gemrb/GUIScripts/GUICommonWindows.py b/gemrb/GUIScripts/GUICommonWindows.py index 6700a67..4cdc333 100644 --- a/gemrb/GUIScripts/GUICommonWindows.py +++ b/gemrb/GUIScripts/GUICommonWindows.py @@ -1110,6 +1110,13 @@ def OpenPortraitWindow (needcontrols=0): Button.SetEvent (IE_GUI_MOUSE_ENTER_BUTTON, PortraitButtonOnMouseEnter) Button.SetEvent (IE_GUI_MOUSE_LEAVE_BUTTON, PortraitButtonOnMouseLeave) + # label for status flags (dialog, store, level up) + if GUICommon.GameIsIWD1(): + Button.CreateLabelOnButton(200 + i, "STATES", IE_FONT_ALIGN_TOP) + else: + Button.CreateLabelOnButton(200 + i, "STATES2", IE_FONT_ALIGN_TOP) + + Label = Window.GetControl(200 + i) if GUICommon.GameIsIWD1(): # overlay a label, so we can display the hp with the correct font. Regular button label # is used by effect icons @@ -1206,14 +1213,14 @@ def UpdatePortraitWindow (): flag = chr(talk) if LUCommon.CanLevelUp (portid+1): - states = flag+blank+chr(255) + states - else: - if GUICommon.GameIsIWD1(): - HPLabel = Window.GetControl (100+portid) - HPLabel.SetText (ratio_str) # TODO: color depending on the ratio - HPLabel.SetTextColor (*color) - else: - states = flag+blank+blank + states + flag = flag + blank + chr(255) + elif GUICommon.GameIsIWD1(): + HPLabel = Window.GetControl (100+portid) + HPLabel.SetText (ratio_str) # TODO: color depending on the ratio + HPLabel.SetTextColor (*color) + if flag <> blank: + FlagLabel = Window.GetControl(200 + portid) + FlagLabel.SetText(flag) Button.SetText(states) return http://gemrb.git.sourceforge.net/git/gitweb.cgi?p=gemrb/gemrb;a=commitdiff;h=4c4c461cc2b79f02207ca56d2706e5fd40f56d19 commit 4c4c461cc2b79f02207ca56d2706e5fd40f56d19 Author: Brad Allred <bra...@me...> Date: Mon Sep 17 18:52:49 2012 -0600 Button: reduce number of calculations / complexity of the image coordinates diff --git a/gemrb/core/GUI/Button.cpp b/gemrb/core/GUI/Button.cpp index 6e49520..618089c 100644 --- a/gemrb/core/GUI/Button.cpp +++ b/gemrb/core/GUI/Button.cpp @@ -216,13 +216,14 @@ void Button::Draw(unsigned short x, unsigned short y) } // Button picture + int picXPos, picYPos; if (Picture && (Flags & IE_GUI_BUTTON_PICTURE) ) { // Picture is drawn centered - int xOffs = ( Width / 2 ) - ( Picture->Width / 2 ); - int yOffs = ( Height / 2 ) - ( Picture->Height / 2 ); + picXPos = ( Width / 2 ) - ( Picture->Width / 2 ) + x + XPos; + picYPos = ( Height / 2 ) - ( Picture->Height / 2 ) + y + YPos; if (Flags & IE_GUI_BUTTON_HORIZONTAL) { - xOffs += x + XPos + Picture->XPos; - yOffs += y + YPos + Picture->YPos; + picXPos += Picture->XPos; + picYPos += Picture->YPos; // Clipping: 0 = overlay over full button, 1 = no overlay int overlayHeight = Picture->Height * (1.0 - Clipping); @@ -232,21 +233,21 @@ void Button::Draw(unsigned short x, unsigned short y) overlayHeight = Picture->Height; int buttonHeight = Picture->Height - overlayHeight; - Region rb = Region(xOffs, yOffs, Picture->Width, buttonHeight); - Region ro = Region(xOffs, yOffs + buttonHeight, Picture->Width, overlayHeight); + Region rb = Region(picXPos, picYPos, Picture->Width, buttonHeight); + Region ro = Region(picXPos, picYPos + buttonHeight, Picture->Width, overlayHeight); - video->BlitSprite( Picture, xOffs, yOffs, true, &rb ); + video->BlitSprite( Picture, picXPos, picYPos, true, &rb ); // TODO: Add an option to add BLIT_GREY to the flags - video->BlitGameSprite( Picture, xOffs, yOffs, BLIT_TINTED, SourceRGB, 0, 0, &ro, true); + video->BlitGameSprite( Picture, picXPos, picYPos, BLIT_TINTED, SourceRGB, 0, 0, &ro, true); // do NOT uncomment this, you can't change Changed or invalidate things from // the middle of Window::DrawWindow() -- it needs moving to somewhere else //CloseUpColor(); } else { - Region r( x + XPos + xOffs, y + YPos + yOffs, (int)(Picture->Width * Clipping), Picture->Height ); - video->BlitSprite( Picture, x + XPos + xOffs + Picture->XPos, y + YPos + yOffs + Picture->YPos, true, &r ); + Region r( picXPos, picYPos, (int)(Picture->Width * Clipping), Picture->Height ); + video->BlitSprite( Picture, picXPos + Picture->XPos, picYPos + Picture->YPos, true, &r ); } } http://gemrb.git.sourceforge.net/git/gitweb.cgi?p=gemrb/gemrb;a=commitdiff;h=ffbc9e1c821986b68e42bd294052af2d28f5e025 commit ffbc9e1c821986b68e42bd294052af2d28f5e025 Author: Brad Allred <bra...@me...> Date: Mon Sep 17 18:50:19 2012 -0600 Font: consistant alignment padding we need 5px padding on for bottom and right alignments to match top alignment and left. lets use a nemed constant while we're at it. diff --git a/gemrb/core/Font.cpp b/gemrb/core/Font.cpp index 19fc76e..8b98f41 100644 --- a/gemrb/core/Font.cpp +++ b/gemrb/core/Font.cpp @@ -35,8 +35,6 @@ namespace GemRB { -#define PARAGRAPH_START_X 5; - #define SET_BLIT_PALETTE( palette )\ if (palette) ((Palette*)palette)->IncRef();\ if (blitPalette) blitPalette->Release();\ @@ -187,7 +185,7 @@ void Font::PrintFromLine(int startrow, Region rgn, const unsigned char* string, } } - unsigned int psx = PARAGRAPH_START_X; + unsigned int psx = IE_FONT_PADDING; Palette *pal = hicolor; if (!pal) { pal = palette; @@ -217,7 +215,7 @@ void Font::PrintFromLine(int startrow, Region rgn, const unsigned char* string, if (Alignment & IE_FONT_ALIGN_CENTER) { x = ( rgn.w - w) / 2; } else if (Alignment & IE_FONT_ALIGN_RIGHT) { - x = ( rgn.w - w ); + x = ( rgn.w - w ) - IE_FONT_PADDING; } if (Alignment & IE_FONT_ALIGN_MIDDLE) { int h = 0; @@ -228,15 +226,15 @@ void Font::PrintFromLine(int startrow, Region rgn, const unsigned char* string, h = h * ystep; y += ( rgn.h - h ) / 2; } else if (Alignment & IE_FONT_ALIGN_BOTTOM) { - int h = 1; + int h = 0; for (size_t i = 0; i <= len; i++) { if (( tmp[i] == 0 ) || ( tmp[i] == '\n' )) h++; } h = h * ystep; - y += ( rgn.h - h ); + y += ( rgn.h - h ) - IE_FONT_PADDING; } else if (Alignment & IE_FONT_ALIGN_TOP) { - y += 5; + y += IE_FONT_PADDING; } Video* video = core->GetVideoDriver(); @@ -284,7 +282,7 @@ void Font::PrintFromLine(int startrow, Region rgn, const unsigned char* string, continue; } if (stricmp( "/p", tag ) == 0) { - psx = PARAGRAPH_START_X; + psx = IE_FONT_PADDING; } continue; } @@ -372,7 +370,7 @@ void Font::Print(Region cliprgn, Region rgn, const unsigned char* string, { int capital = (initials) ? 1 : 0; - unsigned int psx = PARAGRAPH_START_X; + unsigned int psx = IE_FONT_PADDING; Palette* pal = hicolor; if (!pal) { pal = palette; @@ -414,7 +412,7 @@ void Font::Print(Region cliprgn, Region rgn, const unsigned char* string, x = ( rgn.w - w ) / 2; } else if (Alignment & IE_FONT_ALIGN_RIGHT) { int w = CalcStringWidth( tmp, NoColor ); - x = ( rgn.w - w ); + x = ( rgn.w - w ) - IE_FONT_PADDING; } if (Alignment & IE_FONT_ALIGN_MIDDLE) { @@ -426,15 +424,15 @@ void Font::Print(Region cliprgn, Region rgn, const unsigned char* string, h = h * ystep; y += ( rgn.h - h ) / 2; } else if (Alignment & IE_FONT_ALIGN_BOTTOM) { - int h = 1; + int h = 0; for (size_t i = 0; i <= len; i++) { if (tmp[i] == 0) h++; } h = h * ystep; - y += ( rgn.h - h ); + y += ( rgn.h - h ) - IE_FONT_PADDING; } else if (Alignment & IE_FONT_ALIGN_TOP) { - y += 5; + y += IE_FONT_PADDING; } unsigned char currChar = '\0'; @@ -476,7 +474,7 @@ void Font::Print(Region cliprgn, Region rgn, const unsigned char* string, continue; } if (stricmp( "/p", tag ) == 0) { - psx = PARAGRAPH_START_X; + psx = IE_FONT_PADDING; continue; } continue; @@ -539,7 +537,7 @@ int Font::CalcStringWidth(const char* string, bool NoColor) const void Font::SetupString(char* string, unsigned int width, bool NoColor, Font *initials, bool enablecap) const { size_t len = strlen( string ); - unsigned int psx = PARAGRAPH_START_X; + unsigned int psx = IE_FONT_PADDING; int lastpos = 0; unsigned int x = psx, wx = 0; bool endword = false; @@ -603,7 +601,7 @@ void Font::SetupString(char* string, unsigned int width, bool NoColor, Font *ini continue; } if (stricmp( "/p", tag ) == 0) { - psx = PARAGRAPH_START_X; + psx = IE_FONT_PADDING; continue; } continue; diff --git a/gemrb/core/Font.h b/gemrb/core/Font.h index 6da9d56..6816bb2 100644 --- a/gemrb/core/Font.h +++ b/gemrb/core/Font.h @@ -58,6 +58,8 @@ class Sprite2D; #define IE_FONT_ALIGN_MIDDLE 0x20 //Only for single line Text #define IE_FONT_SINGLE_LINE 0x40 +#define IE_FONT_PADDING 5 + /** * @class Font * Class for using and manipulating images serving as fonts ----------------------------------------------------------------------- This is an automated email from the git hooks/post-receive script. -- gemrb: Infinity Engine emulator |