Skip to content

Commit cfeb1cd

Browse files
committed
make transparent guis work ish
1 parent 6aff001 commit cfeb1cd

File tree

3 files changed

+69
-5
lines changed

3 files changed

+69
-5
lines changed

Source/Entities/PieMenu.cpp

Lines changed: 60 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include "PresetMan.h"
66
#include "SettingsMan.h"
77
#include "LuaMan.h"
8+
#include "GLResourceMan.h"
89

910
#include "AHuman.h"
1011
#include "ContentFile.h"
@@ -637,9 +638,13 @@ void PieMenu::Draw(BITMAP* targetBitmap, const Vector& targetPos) const {
637638
if (m_EnabledState != EnabledState::Disabled) {
638639
if (m_DrawBackgroundTransparent && !g_FrameMan.IsInMultiplayerMode()) {
639640
g_FrameMan.SetTransTableFromPreset(TransparencyPreset::MoreTrans);
640-
draw_trans_sprite(targetBitmap, m_BGBitmap, drawPos.GetFloorIntX() - m_BGBitmap->w / 2, drawPos.GetFloorIntY() - m_BGBitmap->h / 2);
641+
//draw_trans_sprite(targetBitmap, m_BGBitmap, drawPos.GetFloorIntX() - m_BGBitmap->w / 2, drawPos.GetFloorIntY() - m_BGBitmap->h / 2);
642+
g_GLResourceMan.UpdateDynamicBitmap(m_BGBitmap, true);
643+
DrawTexture(g_GLResourceMan.GetStaticTextureFromBitmap(m_BGBitmap), drawPos.GetFloorIntX() - m_BGBitmap->w / 2, drawPos.GetFloorIntY() - m_BGBitmap->h / 2, {255, 255, 255, g_FrameMan.GetCurrentAlpha()});
641644
} else {
642-
draw_sprite(targetBitmap, m_BGBitmap, drawPos.GetFloorIntX() - m_BGBitmap->w / 2, drawPos.GetFloorIntY() - m_BGBitmap->h / 2);
645+
//draw_sprite(targetBitmap, m_BGBitmap, drawPos.GetFloorIntX() - m_BGBitmap->w / 2, drawPos.GetFloorIntY() - m_BGBitmap->h / 2);
646+
g_GLResourceMan.UpdateDynamicBitmap(m_BGBitmap, true);
647+
DrawTexture(g_GLResourceMan.GetStaticTextureFromBitmap(m_BGBitmap), drawPos.GetFloorIntX() - m_BGBitmap->w / 2, drawPos.GetFloorIntY() - m_BGBitmap->h / 2, {255, 255, 255, 255});
643648
}
644649
}
645650

@@ -954,6 +959,59 @@ void PieMenu::CalculateDrawPosition(const BITMAP* targetBitmap, const Vector& ta
954959
}
955960
}
956961

962+
void PieMenu::DrawMenuBackground() {
963+
int centerX = IsSubPieMenu() ? 0 : m_BGBitmap->w / 2;
964+
int centerY = IsSubPieMenu() ? 0 : m_BGBitmap->h / 2;
965+
if (m_DirectionIfSubPieMenu == Directions::Up || m_DirectionIfSubPieMenu == Directions::Left) {
966+
centerX = m_BGBitmap->w;
967+
}
968+
if (m_DirectionIfSubPieMenu == Directions::Up || m_DirectionIfSubPieMenu == Directions::Right) {
969+
centerY = m_BGBitmap->h;
970+
}
971+
if (m_DirectionIfSubPieMenu == Directions::Down) {
972+
centerX = -2;
973+
centerY = -2;
974+
}
975+
if (m_DirectionIfSubPieMenu == Directions::Left) {
976+
centerY = -2;
977+
}
978+
float subPieMenuRotationOffset = IsSubPieMenu() ? c_QuarterPI : 0;
979+
980+
bool pieMenuNeedsToBeDrawnRotated = GetRotAngle() - subPieMenuRotationOffset != 0;
981+
BITMAP* bitmapToDrawTo = pieMenuNeedsToBeDrawnRotated ? m_BGRotationBitmap : m_BGBitmap;
982+
983+
bool hasPieSliceWithSubPieMenu = false;
984+
for (const PieSlice* pieSlice: m_CurrentPieSlices) {
985+
if (pieSlice->GetSubPieMenu()) {
986+
hasPieSliceWithSubPieMenu = true;
987+
break;
988+
}
989+
}
990+
991+
DrawRing(Vector2(centerX, centerY), m_CurrentInnerRadius, m_CurrentInnerRadius + m_BackgroundThickness, 0, 2*PI, 36, {255, 255, 255, 75});
992+
993+
if (m_EnabledState == EnabledState::Enabled) {
994+
if (hasPieSliceWithSubPieMenu) {
995+
clear_to_color(m_BGPieSlicesWithSubPieMenuBitmap, ColorKeys::g_MaskColor);
996+
circlefill(m_BGPieSlicesWithSubPieMenuBitmap, centerX, centerY, m_CurrentInnerRadius + m_BackgroundThickness + c_PieSliceWithSubPieMenuExtraThickness, m_BackgroundColor);
997+
}
998+
DrawBackgroundPieSliceSeparators(bitmapToDrawTo, centerX, centerY, subPieMenuRotationOffset);
999+
if (hasPieSliceWithSubPieMenu) {
1000+
circlefill(m_BGPieSlicesWithSubPieMenuBitmap, centerX, centerY, m_CurrentInnerRadius + m_BackgroundThickness, ColorKeys::g_MaskColor);
1001+
draw_sprite(m_BGPieSlicesWithSubPieMenuBitmap, bitmapToDrawTo, 0, 0);
1002+
clear_to_color(bitmapToDrawTo, ColorKeys::g_MaskColor);
1003+
draw_sprite(bitmapToDrawTo, m_BGPieSlicesWithSubPieMenuBitmap, 0, 0);
1004+
}
1005+
}
1006+
1007+
if (bitmapToDrawTo != m_BGBitmap) {
1008+
clear_to_color(m_BGBitmap, ColorKeys::g_MaskColor);
1009+
float rotationAsAllegroAngle = ((GetRotAngle() - subPieMenuRotationOffset) / c_PI) * -128.0F;
1010+
pivot_sprite(m_BGBitmap, bitmapToDrawTo, m_BGBitmap->w / 2, m_BGBitmap->h / 2, centerX, centerY, ftofix(rotationAsAllegroAngle));
1011+
}
1012+
m_BGBitmapNeedsRedrawing = false;
1013+
m_BGPieSlicesWithSubPieMenuBitmapNeedsRedrawing = false;
1014+
}
9571015
void PieMenu::DrawPieIcons(BITMAP* targetBitmap, const Vector& drawPos) const {
9581016
for (const PieSlice* pieSlice: m_CurrentPieSlices) {
9591017
BITMAP* pieSliceIcon = pieSlice->GetAppropriateIcon(pieSlice == m_HoveredPieSlice);

Source/Entities/PieMenu.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,8 @@ namespace RTE {
404404
/// @param drawPos Out parameter, a Vector to be filled in with the position at which the PieMenu should be drawn.
405405
void CalculateDrawPosition(const BITMAP* targetBitmap, const Vector& targetPos, Vector& drawPos) const;
406406

407+
408+
void DrawMenuBackground();
407409
/// Handles drawing icons for PieSlices' visual representation in the PieMenu.
408410
/// @param targetBitmap A pointer to the BITMAP to draw on. Generally a screen BITMAP.
409411
/// @param drawPos The seam corrected position at which the PieMenu is being drawn.

Source/Menus/InventoryMenuGUI.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include "UInputMan.h"
66
#include "MovableMan.h"
77
#include "PresetMan.h"
8+
#include "GLResourceMan.h"
89

910
#include "Controller.h"
1011
#include "AHuman.h"
@@ -1353,15 +1354,18 @@ void InventoryMenuGUI::DrawCarouselMode(BITMAP* targetBitmap, const Vector& draw
13531354
std::list<IntRect> wrappedRectangles;
13541355
g_SceneMan.WrapRect(IntRect(drawPos.GetFloorIntX(), drawPos.GetFloorIntY(), drawPos.GetFloorIntX() + m_CarouselBitmap->w, drawPos.GetFloorIntY() + m_CarouselBitmap->h), wrappedRectangles);
13551356
for (const IntRect& wrappedRectangle: wrappedRectangles) {
1357+
g_GLResourceMan.UpdateDynamicBitmap(m_CarouselBGBitmap.get(), true);
1358+
g_GLResourceMan.UpdateDynamicBitmap(m_CarouselBitmap.get(), true);
13561359
if (m_CarouselBackgroundTransparent && !g_FrameMan.IsInMultiplayerMode()) {
13571360
g_FrameMan.SetTransTableFromPreset(TransparencyPreset::MoreTrans);
1358-
draw_trans_sprite(targetBitmap, m_CarouselBGBitmap.get(), wrappedRectangle.m_Left - m_CarouselBGBitmap->w / 2, wrappedRectangle.m_Top - m_CarouselBGBitmap->h / 2);
1359-
draw_sprite(targetBitmap, m_CarouselBitmap.get(), wrappedRectangle.m_Left - m_CarouselBitmap->w / 2, wrappedRectangle.m_Top - m_CarouselBitmap->h / 2);
1361+
DrawTexture(g_GLResourceMan.GetStaticTextureFromBitmap(m_CarouselBGBitmap.get()), wrappedRectangle.m_Left - m_CarouselBGBitmap->w / 2, wrappedRectangle.m_Top - m_CarouselBGBitmap->h / 2, {255, 255, 255, 75});
1362+
DrawTexture(g_GLResourceMan.GetStaticTextureFromBitmap(m_CarouselBitmap.get()), wrappedRectangle.m_Left - m_CarouselBitmap->w / 2, wrappedRectangle.m_Top - m_CarouselBitmap->h / 2, {255, 255, 255, 255});
13601363
} else {
13611364
if (!hasDrawnAtLeastOnce) {
1365+
13621366
draw_sprite(m_CarouselBGBitmap.get(), m_CarouselBitmap.get(), 0, 0);
13631367
}
1364-
draw_sprite(targetBitmap, m_CarouselBGBitmap.get(), wrappedRectangle.m_Left - m_CarouselBGBitmap->w / 2, wrappedRectangle.m_Top - m_CarouselBGBitmap->h / 2);
1368+
DrawTexture(g_GLResourceMan.GetStaticTextureFromBitmap(m_CarouselBGBitmap.get()), wrappedRectangle.m_Left - m_CarouselBGBitmap->w / 2, wrappedRectangle.m_Top - m_CarouselBGBitmap->h / 2, {255, 255, 255, 255});
13651369
}
13661370
hasDrawnAtLeastOnce = true;
13671371
}

0 commit comments

Comments
 (0)