Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Proper video scaling, sdl blitting, 32bpp resource support, etc. #738

Open
wants to merge 40 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
acae014
Changed screen color depth to 32bpp.
maxrd2 Nov 9, 2018
796e6d9
Resources are loaded and scaled to match display settings.
maxrd2 Oct 26, 2018
b129ef2
Intro video is centered and converted to 32bpp.
maxrd2 Oct 29, 2018
3b5182f
Rewritten blit functions to work with 32bpp.
maxrd2 Nov 9, 2018
32e25bc
Removed map palette code
maxrd2 Jan 24, 2023
38d703d
Removed useless defines.
maxrd2 Nov 11, 2018
adedde9
Cosmetic changes and code cleanup.
maxrd2 Nov 11, 2018
a32c0f9
[WIP] Reworked shading without image palette
maxrd2 Nov 10, 2018
3a821c2
Resources are scaled to match screen resolution.
maxrd2 Nov 9, 2018
679f780
Optional vertical interpolation of scaled images
maxrd2 Jan 18, 2020
411dece
Added optional callback before image scaling
maxrd2 Jan 18, 2020
b25627a
Added optional custom two axis scaling
maxrd2 Jan 25, 2023
a94aad1
Properly scaled credits, main menu, options menu
maxrd2 Oct 29, 2018
463c744
Fixed messagebox and popup scaling. [CLEANUP]
maxrd2 Nov 6, 2018
aff7294
Fixed strategic interface scaling.
maxrd2 Oct 29, 2018
576de5d
Fixed tactical interface scaling.
maxrd2 Nov 7, 2018
175e674
[WIP] Fixed Map Editor for scaling and 32bpp.
maxrd2 Nov 12, 2018
54da363
Tactical tiles and mouse pointer are scaled separately from UI.
maxrd2 Jul 29, 2019
5481f45
Revert "Make four render variables const"
maxrd2 Oct 27, 2023
9081c86
[WIP] Fixed tactical world scaling.
maxrd2 Nov 8, 2018
8c26f23
Removed FloatFromCellToScreenCoordinates()
maxrd2 Jul 29, 2019
3e4ca5e
Fixed sRelativeZ being added twice to y.
maxrd2 Jul 29, 2019
87c36b0
Removed useless gsRenderWorldOffsetX/Y variables.
maxrd2 Jul 29, 2019
6adb231
Fixed inaccurate mouse coordinates.
maxrd2 Jul 30, 2019
3c00f19
Fixed bad float to int conversions/rounding.
maxrd2 Jul 29, 2019
ce64555
Code cleanup without functional changes.
maxrd2 Jul 30, 2019
e3a067f
Fixed regression in interactive tile detection.
maxrd2 Jul 30, 2019
b338278
[WIP] Fixed tactical soldier animation rendering.
maxrd2 Nov 25, 2019
765adac
Refactoring and cleanup
maxrd2 Jan 15, 2020
ddeaeb0
[WIP] Fixed laptop interface scaling.
maxrd2 Nov 9, 2018
fb6a69a
* FIXUP laptop IMP
maxrd2 Jan 18, 2020
c510638
!!! sanity asserts
maxrd2 Jan 24, 2023
fa05be0
!!! fix loading
maxrd2 Jan 24, 2023
aaf5c36
!!! fix crash
maxrd2 Jan 24, 2023
2399d47
!!! tactical clear
maxrd2 Jan 24, 2023
0ecef99
[FIXME] corpse palette crash
maxrd2 Apr 1, 2023
f8ac29d
Changed FPS display to 32bpp [untested]
maxrd2 Oct 27, 2023
d786220
!!! fixed use of std::optional
maxrd2 Oct 27, 2023
4896674
!!! fix compilaton (unique_ptr)
maxrd2 Oct 27, 2023
205c42e
Merge branch 'master' into video-scale
lynxlynxlynx Nov 5, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
69 changes: 40 additions & 29 deletions src/game/Credits.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "Video.h"
#include "WordWrap.h"
#include "UILayout.h"
#include "FontCompat.h"

#include "ContentManager.h"
#include "GameInstance.h"
Expand Down Expand Up @@ -65,30 +66,30 @@ struct CRDT_NODE
#define CRDT_END_OF_SECTION '}'


#define CRDT_NAME_LOC_X (375 + STD_SCREEN_X)
#define CRDT_NAME_LOC_Y (420 + STD_SCREEN_Y)
#define CRDT_NAME_TITLE_LOC_Y (435 + STD_SCREEN_Y)
#define CRDT_NAME_FUNNY_LOC_Y (450 + STD_SCREEN_Y)
#define CRDT_NAME_LOC_WIDTH 260
#define CRDT_NAME_LOC_X (g_ui.m_stdScreenScale * 375 + STD_SCREEN_X)
#define CRDT_NAME_LOC_Y (g_ui.m_stdScreenScale * 420 + STD_SCREEN_Y)
#define CRDT_NAME_TITLE_LOC_Y (g_ui.m_stdScreenScale * 435 + STD_SCREEN_Y)
#define CRDT_NAME_FUNNY_LOC_Y (g_ui.m_stdScreenScale * 450 + STD_SCREEN_Y)
#define CRDT_NAME_LOC_WIDTH (g_ui.m_stdScreenScale * 260)
#define CRDT_NAME_LOC_HEIGHT ( CRDT_NAME_FUNNY_LOC_Y - CRDT_NAME_LOC_Y + GetFontHeight( CRDT_NAME_FONT ) )

#define CRDT_NAME_FONT FONT12ARIAL


#define CRDT_WIDTH_OF_TEXT_AREA 210
#define CRDT_TEXT_START_LOC (10 + STD_SCREEN_X)
#define CRDT_WIDTH_OF_TEXT_AREA (g_ui.m_stdScreenScale * 210)
#define CRDT_TEXT_START_LOC (g_ui.m_stdScreenScale * 10 + STD_SCREEN_X)


#define CRDT_SCROLL_PIXEL_AMOUNT 1
#define CRDT_SCROLL_PIXEL_AMOUNT g_ui.m_stdScreenScale * 1
#define CRDT_NODE_DELAY_AMOUNT 25

#define CRDT_SPACE_BN_SECTIONS 50
#define CRDT_SPACE_BN_NODES 12

#define CRDT_START_POS_Y (SCREEN_HEIGHT - 1 - STD_SCREEN_Y)

#define CRDT_EYE_WIDTH 30
#define CRDT_EYE_HEIGHT 12
#define CRDT_EYE_WIDTH (g_ui.m_stdScreenScale * 30)
#define CRDT_EYE_HEIGHT (g_ui.m_stdScreenScale * 12)

#define CRDT_EYES_CLOSED_TIME 150

Expand Down Expand Up @@ -149,8 +150,8 @@ static INT32 giCurrentlySelectedFace;

static SGPFont guiCreditScreenActiveFont; // the font that is used
static SGPFont guiCreditScreenTitleFont; // the font that is used
static UINT8 gubCreditScreenActiveColor; // color of the font
static UINT8 gubCreditScreenTitleColor; // color of a Title node
static UINT32 gubCreditScreenActiveColor; // color of the font
static UINT32 gubCreditScreenTitleColor; // color of a Title node

static UINT32 guiCrdtNodeScrollSpeed; // speed credits go up at
static UINT32 guiCrdtLastTimeUpdatingNode; // the last time a node was read from the file
Expand Down Expand Up @@ -222,10 +223,10 @@ try
// Make a mouse region
MOUSE_REGION* const r = &gCrdtMouseRegions[i];
CreditFace const& f = gCreditFaces[i];
UINT16 const x = f.sX + STD_SCREEN_X;
UINT16 const y = f.sY + STD_SCREEN_Y;
UINT16 const w = f.sWidth;
UINT16 const h = f.sHeight;
UINT16 const x = g_ui.m_stdScreenScale * f.sX + STD_SCREEN_X;
UINT16 const y = g_ui.m_stdScreenScale * f.sY + STD_SCREEN_Y;
UINT16 const w = g_ui.m_stdScreenScale * f.sWidth;
UINT16 const h = g_ui.m_stdScreenScale * f.sHeight;
MSYS_DefineRegion(r, x, y, x + w, y + h, MSYS_PRIORITY_HIGHEST, CURSOR_WWW, SelectCreditFaceMovementRegionCallBack, MSYS_NO_CALLBACK);
MSYS_SetRegionUserData(r, 0, i);
}
Expand Down Expand Up @@ -287,9 +288,15 @@ static void HandleCreditScreen(void)

if (giCurrentlySelectedFace != -1)
{
DrawTextToScreen(gzCreditNames[giCurrentlySelectedFace], CRDT_NAME_LOC_X, CRDT_NAME_LOC_Y, CRDT_NAME_LOC_WIDTH, CRDT_NAME_FONT, FONT_MCOLOR_WHITE, 0, INVALIDATE_TEXT | CENTER_JUSTIFIED);
DrawTextToScreen(gzCreditNameTitle[giCurrentlySelectedFace], CRDT_NAME_LOC_X, CRDT_NAME_TITLE_LOC_Y, CRDT_NAME_LOC_WIDTH, CRDT_NAME_FONT, FONT_MCOLOR_WHITE, 0, INVALIDATE_TEXT | CENTER_JUSTIFIED);
DrawTextToScreen(gzCreditNameFunny[giCurrentlySelectedFace], CRDT_NAME_LOC_X, CRDT_NAME_FUNNY_LOC_Y, CRDT_NAME_LOC_WIDTH, CRDT_NAME_FONT, FONT_MCOLOR_WHITE, 0, INVALIDATE_TEXT | CENTER_JUSTIFIED);
DrawTextToScreen(gzCreditNames[giCurrentlySelectedFace],
CRDT_NAME_LOC_X, CRDT_NAME_LOC_Y, CRDT_NAME_LOC_WIDTH,
CRDT_NAME_FONT, FONT_MCOLOR_WHITE, FONT_MCOLOR_TRANSPARENT, INVALIDATE_TEXT | CENTER_JUSTIFIED);
DrawTextToScreen(gzCreditNameTitle[giCurrentlySelectedFace],
CRDT_NAME_LOC_X, CRDT_NAME_TITLE_LOC_Y, CRDT_NAME_LOC_WIDTH,
CRDT_NAME_FONT, FONT_MCOLOR_WHITE, FONT_MCOLOR_TRANSPARENT, INVALIDATE_TEXT | CENTER_JUSTIFIED);
DrawTextToScreen(gzCreditNameFunny[giCurrentlySelectedFace],
CRDT_NAME_LOC_X, CRDT_NAME_FUNNY_LOC_Y, CRDT_NAME_LOC_WIDTH,
CRDT_NAME_FONT, FONT_MCOLOR_WHITE, FONT_MCOLOR_TRANSPARENT, INVALIDATE_TEXT | CENTER_JUSTIFIED);
}
}

Expand Down Expand Up @@ -334,7 +341,7 @@ static void AddCreditNode(UINT32 uiFlags, const ST::string& pString)

//Determine the font and the color to use
SGPFont uiFontToUse;
UINT8 uiColorToUse;
UINT32 uiColorToUse;
if (uiFlags & CRDT_FLAG__TITLE)
{
uiFontToUse = guiCreditScreenTitleFont;
Expand All @@ -347,17 +354,14 @@ static void AddCreditNode(UINT32 uiFlags, const ST::string& pString)
}

//Calculate the height of the string
pNodeToAdd->sHeightOfString = DisplayWrappedString(0, 0, CRDT_WIDTH_OF_TEXT_AREA, 2, uiFontToUse, uiColorToUse, pString, 0, DONT_DISPLAY_TEXT) + 1;
pNodeToAdd->sHeightOfString = DisplayWrappedString(0, 0, CRDT_WIDTH_OF_TEXT_AREA, 2, uiFontToUse, uiColorToUse, pString, FONT_MCOLOR_TRANSPARENT, DONT_DISPLAY_TEXT) + 1;

//starting y position on the screen
pNodeToAdd->sPosY = CRDT_START_POS_Y;

SGPVSurface* const vs = AddVideoSurface(CRDT_WIDTH_OF_TEXT_AREA, pNodeToAdd->sHeightOfString, PIXEL_DEPTH);
pNodeToAdd->uiVideoSurfaceImage = vs;

vs->SetTransparency(0);
vs->Fill(0);

//write the string onto the surface
SetFontDestBuffer(vs);
DisplayWrappedString(0, 1, CRDT_WIDTH_OF_TEXT_AREA, 2, uiFontToUse, uiColorToUse, pString, 0, gubCrdtJustification);
Expand Down Expand Up @@ -437,6 +441,13 @@ static UINT32 GetNumber(const char* string)
return v;
}

static UINT32 GetColor(const char* const string)
{
const unsigned int v = GetNumber(string);
Assert(v < 256);
return gColorFromPalette[v];
}


static void HandleCreditFlags(UINT32 uiFlags);

Expand Down Expand Up @@ -467,8 +478,8 @@ static BOOLEAN GetNextCreditFromTextFile(void)
case CRDT_DELAY_BN_STRINGS_CODE: guiGapBetweenCreditNodes = GetNumber(s); break;
case CRDT_DELAY_BN_SECTIONS_CODE: guiGapBetweenCreditSections = GetNumber(s); break;
case CRDT_SCROLL_SPEED: guiCrdtNodeScrollSpeed = GetNumber(s); break;
case CRDT_TITLE_FONT_COLOR: gubCreditScreenTitleColor = GetNumber(s); break;
case CRDT_ACTIVE_FONT_COLOR: gubCreditScreenActiveColor = GetNumber(s); break;
case CRDT_TITLE_FONT_COLOR: gubCreditScreenTitleColor = GetColor(s); break;
case CRDT_ACTIVE_FONT_COLOR: gubCreditScreenActiveColor = GetColor(s); break;

case CRDT_FONT_JUSTIFICATION:
switch (GetNumber(s))
Expand Down Expand Up @@ -553,8 +564,8 @@ static void HandleCreditEyeBlinking()
UINT32 const now = GetJA2Clock();
if (now - f.uiLastBlinkTime > f.sBlinkFreq)
{
INT32 const x = f.sEyeX + STD_SCREEN_X;
INT32 const y = f.sEyeY + STD_SCREEN_Y;
INT32 const x = g_ui.m_stdScreenScale * f.sEyeX + STD_SCREEN_X;
INT32 const y = g_ui.m_stdScreenScale * f.sEyeY + STD_SCREEN_Y;
BltVideoObject(FRAME_BUFFER, guiCreditFaces, gfx, x, y);
InvalidateRegion(x, y, x + CRDT_EYE_WIDTH, y + CRDT_EYE_HEIGHT);

Expand All @@ -563,7 +574,7 @@ static void HandleCreditEyeBlinking()
}
else if (now > f.uiEyesClosedTime)
{
RestoreExternBackgroundRect(f.sEyeX + STD_SCREEN_X, f.sEyeY + STD_SCREEN_Y, CRDT_EYE_WIDTH, CRDT_EYE_HEIGHT);
RestoreExternBackgroundRect(g_ui.m_stdScreenScale * f.sEyeX + STD_SCREEN_X, g_ui.m_stdScreenScale * f.sEyeY + STD_SCREEN_Y, CRDT_EYE_WIDTH, CRDT_EYE_HEIGHT);

f.uiEyesClosedTime = 0;
}
Expand Down
26 changes: 13 additions & 13 deletions src/game/Editor/EditScreen.cc
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,9 @@ static UINT16 PrevCurrentPaste = FIRSTTEXTURE;
static INT32 gPrevCurrentBackground = FIRSTTEXTURE;
static ToolbarMode iPrevJA2ToolbarState = TBAR_MODE_NONE;

UINT16 gusEditorTaskbarColor;
UINT16 gusEditorTaskbarHiColor;
UINT16 gusEditorTaskbarLoColor;
UINT32 gusEditorTaskbarColor;
UINT32 gusEditorTaskbarHiColor;
UINT32 gusEditorTaskbarLoColor;

BOOLEAN gfGotoGridNoUI = FALSE;
static GUIButtonRef guiGotoGridNoUIButtonID;
Expand All @@ -179,13 +179,13 @@ void EditScreenInit(void)

//Set the editor colors.
//gusEditorTaskbarColor = 9581;
//gusEditorTaskbarColor = Get16BPPColor( FROMRGB( 72, 88, 104 ) );
//gusEditorTaskbarHiColor = Get16BPPColor( FROMRGB( 136, 138, 135 ) );
//gusEditorTaskbarLoColor = Get16BPPColor( FROMRGB( 24, 61, 81 ) );
//gusEditorTaskbarColor = RGB(72, 88, 104);
//gusEditorTaskbarHiColor = RGB(136, 138, 135);
//gusEditorTaskbarLoColor = RGB(24, 61, 81);

gusEditorTaskbarColor = Get16BPPColor( FROMRGB( 65, 79, 94 ) );
gusEditorTaskbarHiColor = Get16BPPColor( FROMRGB( 122, 124, 121 ) );
gusEditorTaskbarLoColor = Get16BPPColor( FROMRGB( 22, 55, 73 ) );
gusEditorTaskbarColor = RGB(65, 79, 94);
gusEditorTaskbarHiColor = RGB(122, 124, 121);
gusEditorTaskbarLoColor = RGB(22, 55, 73);

InitArmyGunTypes();
}
Expand Down Expand Up @@ -913,10 +913,10 @@ void ShowCurrentDrawingMode( void )
}

// Set the color for the window's border. Blueish color = Normal, Red = Fake lighting is turned on
UINT16 usFillColor = GetGenericButtonFillColor();
UINT32 usFillColor = GetGenericButtonFillColor();

{ SGPVSurface::Lock l(FRAME_BUFFER);
RectangleDraw(FALSE, x, y, x + w - 1, y + h, usFillColor, l.Buffer<UINT16>());
RectangleDraw(FALSE, x, y, x + w - 1, y + h, usFillColor, l.Buffer<UINT32>());
}

InvalidateRegion(x, y, x + w, y + h);
Expand Down Expand Up @@ -2266,9 +2266,9 @@ static ScreenID WaitForHelpScreenResponse(void)
BOOLEAN fLeaveScreen;

ColorFillVideoSurfaceArea(FRAME_BUFFER, 50, 50, 590, 310,
Get16BPPColor(FROMRGB(136, 138, 135)) );
RGB(136, 138, 135) );
ColorFillVideoSurfaceArea(FRAME_BUFFER, 51, 51, 590, 310,
Get16BPPColor(FROMRGB(24, 61, 81)) );
RGB(24, 61, 81) );
ColorFillVideoSurfaceArea(FRAME_BUFFER, 51, 51, 589, 309, GetGenericButtonFillColor());

SetFont( gp12PointFont1 );
Expand Down
6 changes: 3 additions & 3 deletions src/game/Editor/EditScreen.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ BOOLEAN RemoveLight(GridNo pos);
extern BOOLEAN gfMercResetUponEditorEntry;

//These go together. The taskbar has a specific color scheme.
extern UINT16 gusEditorTaskbarColor;
extern UINT16 gusEditorTaskbarHiColor;
extern UINT16 gusEditorTaskbarLoColor;
extern UINT32 gusEditorTaskbarColor;
extern UINT32 gusEditorTaskbarHiColor;
extern UINT32 gusEditorTaskbarLoColor;

extern TaskMode iOldTaskMode;
extern TaskMode iCurrentTaskbar;
Expand Down
8 changes: 4 additions & 4 deletions src/game/Editor/EditorItems.cc
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ void EntryInitEditorItemsInfo()
}


static void DrawItemCentered(const ItemModel * item, SGPVSurface* const vs, INT32 x, INT32 const y, INT16 const outline)
static void DrawItemCentered(const ItemModel * item, SGPVSurface* const vs, INT32 x, INT32 const y, UINT32 const outline)
{
// Calculate the center position of the graphic in a 60 pixel wide area.
auto graphic = GetSmallInventoryGraphicForItem(item);
Expand Down Expand Up @@ -484,7 +484,7 @@ void DetermineItemsScrolling()
static UINT16 CountNumberOfEditorPlacementsInWorld(UINT16 usEInfoIndex, UINT16* pusQuantity);


static void drawItemWithOutline(INT16 min_idx, INT16 end_idx, INT16 scroll_idx, INT16 itemIndex, INT16 const outline)
static void drawItemWithOutline(INT16 min_idx, INT16 end_idx, INT16 scroll_idx, INT16 itemIndex, UINT32 const outline)
{
if (min_idx <= itemIndex && itemIndex < end_idx)
{
Expand Down Expand Up @@ -519,8 +519,8 @@ void RenderEditorItemsInfo()
// Draw the hilighted and selected items if applicable.
if (eInfo.pusItemIndex)
{
drawItemWithOutline(min_idx, end_idx, scroll_idx, eInfo.sHilitedItemIndex, Get16BPPColor(FROMRGB(250, 250, 0)));
drawItemWithOutline(min_idx, end_idx, scroll_idx, eInfo.sSelItemIndex, Get16BPPColor(FROMRGB(250, 0, 0)));
drawItemWithOutline(min_idx, end_idx, scroll_idx, eInfo.sHilitedItemIndex, RGB(250, 250, 0));
drawItemWithOutline(min_idx, end_idx, scroll_idx, eInfo.sSelItemIndex, RGB(250, 0, 0));
}

// Draw the numbers of each visible item that currently resides in the world.
Expand Down