Skip to content
This repository has been archived by the owner on Mar 8, 2024. It is now read-only.

Commit

Permalink
Remove the hardcoded 640x480 values from the transform lambdas used w…
Browse files Browse the repository at this point in the history
…ith blitNamedBitmapFromArea
  • Loading branch information
m-flak committed Sep 3, 2022
1 parent cc9e3df commit 5b892f6
Show file tree
Hide file tree
Showing 14 changed files with 173 additions and 98 deletions.
14 changes: 9 additions & 5 deletions src/libdev/machgui/chatwind.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,19 @@ ostream& operator <<( ostream& o, const MachGuiChatWindow& t )
void MachGuiChatWindow::doDisplay()
{
// Blit background to list box item
auto backdrop = pRootParent_->getSharedBitmaps()->getNamedBitmap("backdrop");
pRootParent_->getSharedBitmaps()->blitNamedBitmapFromArea(
auto* shared = pRootParent_->getSharedBitmaps();
auto backdrop = shared->getNamedBitmap("backdrop");
shared->blitNamedBitmapFromArea(
backdrop,
absoluteBoundary(),
absoluteBoundary().minCorner(),
[](const Gui::Box& box) {
//TODO: Stop using hardcoded values for the menu background graphic
[shared, backdrop](const Gui::Box& box) {
using namespace machgui::helper::menus;
return centered_bitmap_transform(box, 640, 480);
return centered_bitmap_transform(
box,
shared->getWidthOfNamedBitmap(backdrop),
shared->getHeightOfNamedBitmap(backdrop)
);
});

GuiBmpFont font( GuiBmpFont::getFont("gui/menu/smallfnt.bmp") );
Expand Down
14 changes: 9 additions & 5 deletions src/libdev/machgui/ctxready.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -608,15 +608,19 @@ void MachGuiCtxImReady::updateGameSettings()
pReadOnlySettings_->deleteAllChildren();

// Blit background to read only list box
auto backdrop = pStartupScreens_->getSharedBitmaps()->getNamedBitmap("backdrop");
pStartupScreens_->getSharedBitmaps()->blitNamedBitmapFromArea(
auto* shared = pStartupScreens_->getSharedBitmaps();
auto backdrop = shared->getNamedBitmap("backdrop");
shared->blitNamedBitmapFromArea(
backdrop,
pReadOnlySettings_->absoluteBoundary(),
pReadOnlySettings_->absoluteBoundary().minCorner(),
[](const Gui::Box& box) {
//TODO: Stop using hardcoded values for the menu background graphic
[shared, backdrop](const Gui::Box& box) {
using namespace machgui::helper::menus;
return centered_bitmap_transform(box, 640, 480);
return centered_bitmap_transform(
box,
shared->getWidthOfNamedBitmap(backdrop),
shared->getHeightOfNamedBitmap(backdrop)
);
});

int textWidth = (SETTINGS_MAXX-SETTINGS_MINX)*0.66;
Expand Down
28 changes: 18 additions & 10 deletions src/libdev/machgui/ctxscenr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -510,15 +510,19 @@ void MachGuiCtxScenario::updatePlanetList( MachGuiDbSystem& system )
pPlanetList_->deleteAllItems();

// Redraw backdrop to list
auto backdrop = pStartupScreens_->getSharedBitmaps()->getNamedBitmap("backdrop");
pStartupScreens_->getSharedBitmaps()->blitNamedBitmapFromArea(
auto* shared = pStartupScreens_->getSharedBitmaps();
auto backdrop = shared->getNamedBitmap("backdrop");
shared->blitNamedBitmapFromArea(
backdrop,
pPlanetList_->absoluteBoundary(),
pPlanetList_->absoluteBoundary().minCorner(),
[](const Gui::Box& box) {
//TODO: Stop using hardcoded values for the menu background graphic
[shared, backdrop](const Gui::Box& box) {
using namespace machgui::helper::menus;
return centered_bitmap_transform(box, 640, 480);
return centered_bitmap_transform(
box,
shared->getWidthOfNamedBitmap(backdrop),
shared->getHeightOfNamedBitmap(backdrop)
);
});

// Insert new items into list
Expand Down Expand Up @@ -572,15 +576,19 @@ void MachGuiCtxScenario::updateScenarioList( MachGuiDbPlanet& planet )
pScenarioList_->deleteAllItems();

// Redraw backdrop to list
auto backdrop = pStartupScreens_->getSharedBitmaps()->getNamedBitmap("backdrop");
pStartupScreens_->getSharedBitmaps()->blitNamedBitmapFromArea(
auto* shared = pStartupScreens_->getSharedBitmaps();
auto backdrop = shared->getNamedBitmap("backdrop");
shared->blitNamedBitmapFromArea(
backdrop,
pScenarioList_->absoluteBoundary(),
pScenarioList_->absoluteBoundary().minCorner(),
[](const Gui::Box& box) {
//TODO: Stop using hardcoded values for the menu background graphic
[shared, backdrop](const Gui::Box& box) {
using namespace machgui::helper::menus;
return centered_bitmap_transform(box, 640, 480);
return centered_bitmap_transform(
box,
shared->getWidthOfNamedBitmap(backdrop),
shared->getHeightOfNamedBitmap(backdrop)
);
});

// Insert new items into list
Expand Down
42 changes: 27 additions & 15 deletions src/libdev/machgui/ctxsetng.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -316,15 +316,19 @@ void MachGuiCtxSettings::updateTerrainTypeList( MachGuiDbSystem& system )
pTerrainTypeList_->deleteAllItems();

// Redraw backdrop to list
auto backdrop = pStartupScreens_->getSharedBitmaps()->getNamedBitmap("backdrop");
pStartupScreens_->getSharedBitmaps()->blitNamedBitmapFromArea(
auto* shared = pStartupScreens_->getSharedBitmaps();
auto backdrop = shared->getNamedBitmap("backdrop");
shared->blitNamedBitmapFromArea(
backdrop,
pTerrainTypeList_->absoluteBoundary(),
pTerrainTypeList_->absoluteBoundary().minCorner(),
[](const Gui::Box& box) {
//TODO: Stop using hardcoded values for the menu background graphic
[shared, backdrop](const Gui::Box& box) {
using namespace machgui::helper::menus;
return centered_bitmap_transform(box, 640, 480);
return centered_bitmap_transform(
box,
shared->getWidthOfNamedBitmap(backdrop),
shared->getHeightOfNamedBitmap(backdrop)
);
});

// Insert new items into list
Expand Down Expand Up @@ -360,15 +364,19 @@ void MachGuiCtxSettings::updateScenarioList( MachGuiDbPlanet& planet )
pScenarioList_->deleteAllItems();

// Redraw backdrop to list
auto backdrop = pStartupScreens_->getSharedBitmaps()->getNamedBitmap("backdrop");
pStartupScreens_->getSharedBitmaps()->blitNamedBitmapFromArea(
auto* shared = pStartupScreens_->getSharedBitmaps();
auto backdrop = shared->getNamedBitmap("backdrop");
shared->blitNamedBitmapFromArea(
backdrop,
pScenarioList_->absoluteBoundary(),
pScenarioList_->absoluteBoundary().minCorner(),
[](const Gui::Box& box) {
//TODO: Stop using hardcoded values for the menu background graphic
[shared, backdrop](const Gui::Box& box) {
using namespace machgui::helper::menus;
return centered_bitmap_transform(box, 640, 480);
return centered_bitmap_transform(
box,
shared->getWidthOfNamedBitmap(backdrop),
shared->getHeightOfNamedBitmap(backdrop)
);
});

// Insert new items into list
Expand Down Expand Up @@ -453,15 +461,19 @@ void MachGuiCtxSettings::initSettings()
pSettingsList_->deleteAllChildren();

// Redraw backdrop to list
auto backdrop = pStartupScreens_->getSharedBitmaps()->getNamedBitmap("backdrop");
pStartupScreens_->getSharedBitmaps()->blitNamedBitmapFromArea(
auto* shared = pStartupScreens_->getSharedBitmaps();
auto backdrop = shared->getNamedBitmap("backdrop");
shared->blitNamedBitmapFromArea(
backdrop,
pSettingsList_->absoluteBoundary(),
pSettingsList_->absoluteBoundary().minCorner(),
[](const Gui::Box& box) {
//TODO: Stop using hardcoded values for the menu background graphic
[shared, backdrop](const Gui::Box& box) {
using namespace machgui::helper::menus;
return centered_bitmap_transform(box, 640, 480);
return centered_bitmap_transform(
box,
shared->getWidthOfNamedBitmap(backdrop),
shared->getHeightOfNamedBitmap(backdrop)
);
});


Expand Down
45 changes: 28 additions & 17 deletions src/libdev/machgui/ctxskirm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -390,19 +390,23 @@ void MachGuiCtxSkirmish::updateTerrainTypeList( MachGuiDbSystem& system )
pTerrainTypeList_->deleteAllItems();

// Redraw backdrop to list
auto backdrop = pStartupScreens_->getSharedBitmaps()->getNamedBitmap("backdrop");
pStartupScreens_->getSharedBitmaps()->blitNamedBitmapFromArea(
auto* shared = pStartupScreens_->getSharedBitmaps();
auto backdrop = shared->getNamedBitmap("backdrop");
shared->blitNamedBitmapFromArea(
backdrop,
pTerrainTypeList_->absoluteBoundary(),
pTerrainTypeList_->absoluteBoundary().minCorner(),
[](const Gui::Box& box) {
//TODO: Stop using hardcoded values for the menu background graphic
[shared, backdrop](const Gui::Box& box) {
using namespace machgui::helper::menus;
return centered_bitmap_transform(box, 640, 480);
return centered_bitmap_transform(
box,
shared->getWidthOfNamedBitmap(backdrop),
shared->getHeightOfNamedBitmap(backdrop)
);
});


// Insert new items into list
// Insert new items into list
uint numPlanets = system.nPlanets();
bool firstItem = true;

Expand All @@ -428,15 +432,19 @@ void MachGuiCtxSkirmish::updateScenarioList( MachGuiDbPlanet& planet )
pScenarioList_->deleteAllItems();

// Redraw backdrop to list
auto backdrop = pStartupScreens_->getSharedBitmaps()->getNamedBitmap("backdrop");
pStartupScreens_->getSharedBitmaps()->blitNamedBitmapFromArea(
auto* shared = pStartupScreens_->getSharedBitmaps();
auto backdrop = shared->getNamedBitmap("backdrop");
shared->blitNamedBitmapFromArea(
backdrop,
pScenarioList_->absoluteBoundary(),
pScenarioList_->absoluteBoundary().minCorner(),
[](const Gui::Box& box) {
//TODO: Stop using hardcoded values for the menu background graphic
[shared, backdrop](const Gui::Box& box) {
using namespace machgui::helper::menus;
return centered_bitmap_transform(box, 640, 480);
return centered_bitmap_transform(
box,
shared->getWidthOfNamedBitmap(backdrop),
shared->getHeightOfNamedBitmap(backdrop)
);
});

// Insert new items into list
Expand Down Expand Up @@ -472,18 +480,21 @@ void MachGuiCtxSkirmish::initSettings()
pSettingsList_->deleteAllChildren();

// Redraw backdrop to list
auto backdrop = pStartupScreens_->getSharedBitmaps()->getNamedBitmap("backdrop");
pStartupScreens_->getSharedBitmaps()->blitNamedBitmapFromArea(
auto* shared = pStartupScreens_->getSharedBitmaps();
auto backdrop = shared->getNamedBitmap("backdrop");
shared->blitNamedBitmapFromArea(
backdrop,
pSettingsList_->absoluteBoundary(),
pSettingsList_->absoluteBoundary().minCorner(),
[](const Gui::Box& box) {
//TODO: Stop using hardcoded values for the menu background graphic
[shared, backdrop](const Gui::Box& box) {
using namespace machgui::helper::menus;
return centered_bitmap_transform(box, 640, 480);
return centered_bitmap_transform(
box,
shared->getWidthOfNamedBitmap(backdrop),
shared->getHeightOfNamedBitmap(backdrop)
);
});


// Add "fog of war" setting...
addSetting( false, pFogOfWarSelector_, IDS_MENU_FOGOFWAR, 2, IDS_MENU_ON, IDS_MENU_OFF );
pFogOfWarSelector_->text( pStartupScreens_->startupData()->fogOfWarStr() );
Expand Down
14 changes: 9 additions & 5 deletions src/libdev/machgui/dropdwnc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -238,15 +238,19 @@ void MachGuiDropDownListBoxCreator::doDisplay()
}
else
{
auto backdrop = pRootParent_->getSharedBitmaps()->getNamedBitmap("backdrop");
pRootParent_->getSharedBitmaps()->blitNamedBitmapFromArea(
auto* shared = pRootParent_->getSharedBitmaps();
auto backdrop = shared->getNamedBitmap("backdrop");
shared->blitNamedBitmapFromArea(
backdrop,
absoluteBoundary(),
absoluteBoundary().minCorner(),
[](const Gui::Box& box) {
//TODO: Stop using hardcoded values for the menu background graphic
[shared, backdrop](const Gui::Box& box) {
using namespace machgui::helper::menus;
return centered_bitmap_transform(box, 640, 480);
return centered_bitmap_transform(
box,
shared->getWidthOfNamedBitmap(backdrop),
shared->getHeightOfNamedBitmap(backdrop)
);
});

// Draw list box item text
Expand Down
14 changes: 9 additions & 5 deletions src/libdev/machgui/editbox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,19 @@ MachGuiSingleLineEditBox::~MachGuiSingleLineEditBox()
//virtual
void MachGuiSingleLineEditBox::drawBackground()
{
auto backdrop = pRootParent_->getSharedBitmaps()->getNamedBitmap("backdrop");
pRootParent_->getSharedBitmaps()->blitNamedBitmapFromArea(
auto* shared = pRootParent_->getSharedBitmaps();
auto backdrop = shared->getNamedBitmap("backdrop");
shared->blitNamedBitmapFromArea(
backdrop,
absoluteBoundary(),
absoluteBoundary().minCorner(),
[](const Gui::Box& box) {
//TODO: Stop using hardcoded values for the menu background graphic
[shared, backdrop](const Gui::Box& box) {
using namespace machgui::helper::menus;
return centered_bitmap_transform(box, 640, 480);
return centered_bitmap_transform(
box,
shared->getWidthOfNamedBitmap(backdrop),
shared->getHeightOfNamedBitmap(backdrop)
);
});
}

Expand Down
28 changes: 18 additions & 10 deletions src/libdev/machgui/menubutn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,28 +150,36 @@ void MachGuiMenuButton::doDisplay()
{
if (msgBoxButton_)
{
auto msgBoxBackdrop = pRootParent_->getSharedBitmaps()->getNamedBitmap("msgbox");
pRootParent_->getSharedBitmaps()->blitNamedBitmapFromArea(
auto* shared = pRootParent_->getSharedBitmaps();
auto msgBoxBackdrop = shared->getNamedBitmap("msgbox");
shared->blitNamedBitmapFromArea(
msgBoxBackdrop,
absoluteBoundary(),
absoluteBoundary().minCorner(),
[](const Gui::Box& box) {
//TODO: Stop using hardcoded values for the menu background graphic
[shared, msgBoxBackdrop](const Gui::Box& box) {
using namespace machgui::helper::menus;
return centered_bitmap_transform(box, 640, 480);
return centered_bitmap_transform(
box,
shared->getWidthOfNamedBitmap(msgBoxBackdrop),
shared->getHeightOfNamedBitmap(msgBoxBackdrop)
);
});
}
else
{
auto backdrop = pRootParent_->getSharedBitmaps()->getNamedBitmap("backdrop");
pRootParent_->getSharedBitmaps()->blitNamedBitmapFromArea(
auto* shared = pRootParent_->getSharedBitmaps();
auto backdrop = shared->getNamedBitmap("backdrop");
shared->blitNamedBitmapFromArea(
backdrop,
absoluteBoundary(),
absoluteBoundary().minCorner(),
[](const Gui::Box& box) {
//TODO: Stop using hardcoded values for the menu background graphic
[shared, backdrop](const Gui::Box& box) {
using namespace machgui::helper::menus;
return centered_bitmap_transform(box, 640, 480);
return centered_bitmap_transform(
box,
shared->getWidthOfNamedBitmap(backdrop),
shared->getHeightOfNamedBitmap(backdrop)
);
});
}

Expand Down
14 changes: 9 additions & 5 deletions src/libdev/machgui/playerit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -333,15 +333,19 @@ void MachGuiPlayerListItem::doDisplay()
else
{
// Blit background to list box item
auto backdrop = pRootParent_->getSharedBitmaps()->getNamedBitmap("backdrop");
pRootParent_->getSharedBitmaps()->blitNamedBitmapFromArea(
auto* shared = pRootParent_->getSharedBitmaps();
auto backdrop = shared->getNamedBitmap("backdrop");
shared->blitNamedBitmapFromArea(
backdrop,
absoluteBoundary(),
absoluteBoundary().minCorner(),
[](const Gui::Box& box) {
//TODO: Stop using hardcoded values for the menu background graphic
[shared, backdrop](const Gui::Box& box) {
using namespace machgui::helper::menus;
return centered_bitmap_transform(box, 640, 480);
return centered_bitmap_transform(
box,
shared->getWidthOfNamedBitmap(backdrop),
shared->getHeightOfNamedBitmap(backdrop)
);
});

// Blit host icon
Expand Down
Loading

0 comments on commit 5b892f6

Please sign in to comment.