Skip to content

Commit 23bee9f

Browse files
authored
Add IFACE_BAR_WIDTH support (#188)
1 parent 3ec827d commit 23bee9f

File tree

5 files changed

+161
-82
lines changed

5 files changed

+161
-82
lines changed

src/display_monitor.cc

Lines changed: 36 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ namespace fallout {
3030

3131
#define DISPLAY_MONITOR_X (23)
3232
#define DISPLAY_MONITOR_Y (24)
33-
#define DISPLAY_MONITOR_WIDTH (167)
33+
#define DISPLAY_MONITOR_WIDTH (167 + gInterfaceBarContentOffset)
3434
#define DISPLAY_MONITOR_HEIGHT (60)
3535

3636
#define DISPLAY_MONITOR_HALF_HEIGHT (DISPLAY_MONITOR_HEIGHT / 2)
@@ -59,12 +59,7 @@ static bool gDisplayMonitorInitialized = false;
5959
// The rectangle that display monitor occupies in the main interface window.
6060
//
6161
// 0x518510
62-
static const Rect gDisplayMonitorRect = {
63-
DISPLAY_MONITOR_X,
64-
DISPLAY_MONITOR_Y,
65-
DISPLAY_MONITOR_X + DISPLAY_MONITOR_WIDTH - 1,
66-
DISPLAY_MONITOR_Y + DISPLAY_MONITOR_HEIGHT - 1,
67-
};
62+
static Rect gDisplayMonitorRect;
6863

6964
// 0x518520
7065
static int gDisplayMonitorScrollDownButton = -1;
@@ -106,6 +101,13 @@ static int gConsoleFilePrintCount = 0;
106101
int displayMonitorInit()
107102
{
108103
if (!gDisplayMonitorInitialized) {
104+
gDisplayMonitorRect = {
105+
DISPLAY_MONITOR_X,
106+
DISPLAY_MONITOR_Y,
107+
DISPLAY_MONITOR_X + DISPLAY_MONITOR_WIDTH - 1,
108+
DISPLAY_MONITOR_Y + DISPLAY_MONITOR_HEIGHT - 1,
109+
};
110+
109111
int oldFont = fontGetCurrent();
110112
fontSetCurrent(DISPLAY_MONITOR_FONT);
111113

@@ -120,24 +122,35 @@ int displayMonitorInit()
120122
return -1;
121123
}
122124

123-
CacheEntry* backgroundFrmHandle;
124-
int backgroundFid = buildFid(OBJ_TYPE_INTERFACE, 16, 0, 0, 0);
125-
Art* backgroundFrm = artLock(backgroundFid, &backgroundFrmHandle);
126-
if (backgroundFrm == NULL) {
127-
internal_free(gDisplayMonitorBackgroundFrmData);
128-
return -1;
129-
}
125+
if (gInterfaceBarIsCustom) {
126+
_intface_full_width = gInterfaceBarWidth;
127+
blitBufferToBuffer(customInterfaceBarGetBackgroundImageData() + gInterfaceBarWidth * DISPLAY_MONITOR_Y + DISPLAY_MONITOR_X,
128+
DISPLAY_MONITOR_WIDTH,
129+
DISPLAY_MONITOR_HEIGHT,
130+
gInterfaceBarWidth,
131+
gDisplayMonitorBackgroundFrmData,
132+
DISPLAY_MONITOR_WIDTH);
133+
} else {
134+
CacheEntry* backgroundFrmHandle;
135+
int backgroundFid = buildFid(OBJ_TYPE_INTERFACE, 16, 0, 0, 0);
136+
Art* backgroundFrm = artLock(backgroundFid, &backgroundFrmHandle);
137+
if (backgroundFrm == NULL) {
138+
internal_free(gDisplayMonitorBackgroundFrmData);
139+
return -1;
140+
}
130141

131-
unsigned char* backgroundFrmData = artGetFrameData(backgroundFrm, 0, 0);
132-
_intface_full_width = artGetWidth(backgroundFrm, 0, 0);
133-
blitBufferToBuffer(backgroundFrmData + _intface_full_width * DISPLAY_MONITOR_Y + DISPLAY_MONITOR_X,
134-
DISPLAY_MONITOR_WIDTH,
135-
DISPLAY_MONITOR_HEIGHT,
136-
_intface_full_width,
137-
gDisplayMonitorBackgroundFrmData,
138-
DISPLAY_MONITOR_WIDTH);
142+
unsigned char* backgroundFrmData = artGetFrameData(backgroundFrm, 0, 0);
143+
_intface_full_width = artGetWidth(backgroundFrm, 0, 0);
139144

140-
artUnlock(backgroundFrmHandle);
145+
blitBufferToBuffer(backgroundFrmData + _intface_full_width * DISPLAY_MONITOR_Y + DISPLAY_MONITOR_X,
146+
DISPLAY_MONITOR_WIDTH,
147+
DISPLAY_MONITOR_HEIGHT,
148+
_intface_full_width,
149+
gDisplayMonitorBackgroundFrmData,
150+
DISPLAY_MONITOR_WIDTH);
151+
152+
artUnlock(backgroundFrmHandle);
153+
}
141154

142155
gDisplayMonitorScrollUpButton = buttonCreate(gInterfaceBarWindow,
143156
DISPLAY_MONITOR_X,

0 commit comments

Comments
 (0)