Skip to content

Commit

Permalink
Improve title bar and make it configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
FeralChild64 committed Mar 21, 2024
1 parent c5afb81 commit 95055de
Show file tree
Hide file tree
Showing 30 changed files with 1,142 additions and 282 deletions.
7 changes: 2 additions & 5 deletions contrib/resources/translations/de.lng
Original file line number Diff line number Diff line change
Expand Up @@ -444,11 +444,8 @@ Verwendung: [color=light-green]config [reset]-set [color=light-cyan][ABSCHNITT][
:TITLEBAR_CYCLES_MS
Zyklen/ms
.
:TITLEBAR_HINT_PAUSED
(PAUSIERT)
.
:TITLEBAR_HINT_NOMOUSE
Keine Maus
:TITLEBAR_PAUSED
PAUSIERT
.
:TITLEBAR_HINT_CAPTURED_HOTKEY
Maus umgeschaltet, %s+F10 zum Freigeben
Expand Down
7 changes: 2 additions & 5 deletions contrib/resources/translations/en.lng
Original file line number Diff line number Diff line change
Expand Up @@ -433,11 +433,8 @@ Usage: [color=light-green]config [reset]-set [color=light-cyan][SECTION][reset]
:TITLEBAR_CYCLES_MS
cycles/ms
.
:TITLEBAR_HINT_PAUSED
(PAUSED)
.
:TITLEBAR_HINT_NOMOUSE
no-mouse mode
:TITLEBAR_PAUSED
PAUSED
.
:TITLEBAR_HINT_CAPTURED_HOTKEY
mouse captured, %s+F10 to release
Expand Down
7 changes: 2 additions & 5 deletions contrib/resources/translations/it.lng
Original file line number Diff line number Diff line change
Expand Up @@ -443,11 +443,8 @@ Utilizzo: [color=light-green]config [reset]-set [color=light-cyan][SEZIONE][rese
:TITLEBAR_CYCLES_MS
cicli/ms
.
:TITLEBAR_HINT_PAUSED
(PAUSA)
.
:TITLEBAR_HINT_NOMOUSE
modalità senza mouse
:TITLEBAR_PAUSED
PAUSA
.
:TITLEBAR_HINT_CAPTURED_HOTKEY
mouse catturato, %s+F10 per rilasciarlo
Expand Down
7 changes: 2 additions & 5 deletions contrib/resources/translations/nl.lng
Original file line number Diff line number Diff line change
Expand Up @@ -447,11 +447,8 @@ Gebruik: [color=light-green]config [reset]-set [color=light-cyan][SECTIE][reset]
:TITLEBAR_CYCLES_MS
cycli/ms
.
:TITLEBAR_HINT_PAUSED
(PAUZE)
.
:TITLEBAR_HINT_NOMOUSE
geen-muis-modus
:TITLEBAR_PAUSED
PAUZE
.
:TITLEBAR_HINT_CAPTURED_HOTKEY
muis gevangen, %s+F10 om los te laten
Expand Down
7 changes: 2 additions & 5 deletions contrib/resources/translations/pl.lng
Original file line number Diff line number Diff line change
Expand Up @@ -430,11 +430,8 @@ Składnia: [color=light-green]config [/reset]-set [color=light-cyan][SECTION][/r
:TITLEBAR_CYCLES_MS
cykli/ms
.
:TITLEBAR_HINT_PAUSED
(PAUZA)
.
:TITLEBAR_HINT_NOMOUSE
tryb bez użycia myszy
:TITLEBAR_PAUSED
PAUZA
.
:TITLEBAR_HINT_CAPTURED_HOTKEY
mysz przejęta, wciśnij %s+F10 aby zwolnić
Expand Down
7 changes: 2 additions & 5 deletions contrib/resources/translations/ru.lng
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
:TITLEBAR_CYCLES_MS
циклов/мс
.
:TITLEBAR_HINT_PAUSED
(ПАУЗА)
.
:TITLEBAR_HINT_NOMOUSE
режим без мыши
:TITLEBAR_PAUSED
ПАУЗА
.
:TITLEBAR_HINT_CAPTURED_HOTKEY
мышь захвачена, %s+F10 для высвобождения
Expand Down
9 changes: 7 additions & 2 deletions include/dos_inc.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,16 @@ extern uint8_t dos_copybuf[0x10000];

void DOS_SetError(uint16_t code);

/* File Handling Routines */
// Guest OS booting routines

void DOS_NotifyBooting();
bool DOS_IsGuestOsBooted();

// File handling routines

enum { STDIN=0,STDOUT=1,STDERR=2,STDAUX=3,STDPRN=4};
enum { HAND_NONE=0,HAND_FILE,HAND_DEVICE};

/* Routines for File Class */
void DOS_SetupFiles (void);
bool DOS_ReadFile(uint16_t handle,uint8_t * data,uint16_t * amount, bool fcb = false);
bool DOS_WriteFile(uint16_t handle,uint8_t * data,uint16_t * amount,bool fcb = false);
Expand All @@ -131,6 +135,7 @@ uint16_t DOS_GetBiosTimePacked();
uint16_t DOS_GetBiosDatePacked();

// Date and Time Conversion

constexpr uint16_t DOS_PackTime(const uint16_t hour,
const uint16_t min,
const uint16_t sec) noexcept
Expand Down
16 changes: 9 additions & 7 deletions include/sdlmain.h
Original file line number Diff line number Diff line change
Expand Up @@ -172,13 +172,22 @@ enum PRIORITY_LEVELS {
PRIORITY_LEVEL_HIGHEST
};

enum class SDL_DosBoxEvents : uint8_t {
RefreshAnimatedTitle,
NumEvents // dummy, keep last, do not use
};

struct SDL_Block {
bool initialized = false;
bool active = false; // If this isn't set don't draw
bool updating = false;
bool resizing_window = false;
bool wait_on_error = false;

uint32_t start_event_id = UINT32_MAX;

bool is_paused = false;

RenderingBackend rendering_backend = RenderingBackend::Texture;
RenderingBackend want_rendering_backend = RenderingBackend::Texture;

Expand Down Expand Up @@ -246,13 +255,6 @@ struct SDL_Block {
double preferred_host_rate = 0.0;
} desktop = {};

struct {
int num_cycles = 0;
std::string hint_mouse_str = {};
std::string hint_paused_str = {};
std::string cycles_ms_str = {};
} title_bar = {};

struct {
VsyncSettings when_windowed = {};
VsyncSettings when_fullscreen = {};
Expand Down
27 changes: 18 additions & 9 deletions include/video.h
Original file line number Diff line number Diff line change
Expand Up @@ -401,16 +401,25 @@ void GFX_EndUpdate( const uint16_t *changedLines );
void GFX_LosingFocus();
void GFX_RegenerateWindow(Section *sec);

void GFX_RefreshTitle();
void GFX_RefreshAnimatedTitle();
void GFX_NotifyBooting();
void GFX_NotifyAudioCaptureStatus(const bool is_capturing);
void GFX_NotifyVideoCaptureStatus(const bool is_capturing);
void GFX_NotifyAudioMutedStatus(const bool is_muted);
void GFX_NotifyProgramName(const std::string& segment_name,
const std::string& canonical_name);
void GFX_NotifyCyclesChanged(const int32_t cycles);

enum class MouseHint {
None, // no hint to display
NoMouse, // no mouse mode
CapturedHotkey, // mouse captured, use hotkey to release
CapturedHotkeyMiddle, // mouse captured, use hotkey or middle-click to release
ReleasedHotkey, // mouse released, use hotkey to capture
ReleasedHotkeyMiddle, // mouse released, use hotkey or middle-click to capture
ReleasedHotkeyAnyButton, // mouse released, use hotkey or any click to capture
SeamlessHotkey, // seamless mouse, use hotkey to capture
SeamlessHotkeyMiddle, // seamless mouse, use hotkey or middle-click to capture
None, // no hint to display
CapturedHotkey, // captured, hotkey to release
CapturedHotkeyMiddle, // captured, hotkey or middle-click release
ReleasedHotkey, // released, hotkey to capture
ReleasedHotkeyMiddle, // released, hotkey or middle-click to capture
ReleasedHotkeyAnyButton, // released, hotkey or any click to capture
SeamlessHotkey, // seamless, hotkey to capture
SeamlessHotkeyMiddle, // seamless, hotkey or middle-click to capture
};

void GFX_CenterMouse();
Expand Down
3 changes: 3 additions & 0 deletions src/capture/capture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,7 @@ void CAPTURE_StartVideoCapture()
switch (capture.state.video) {
case CaptureState::Off:
capture.state.video = CaptureState::Pending;
GFX_NotifyVideoCaptureStatus(true);
break;
case CaptureState::Pending:
case CaptureState::InProgress:
Expand All @@ -376,10 +377,12 @@ void CAPTURE_StopVideoCapture()
// completeness only
LOG_MSG("CAPTURE: Cancelling pending video output capture");
capture.state.video = CaptureState::Off;
GFX_NotifyVideoCaptureStatus(false);
break;
case CaptureState::InProgress:
capture_video_finalise();
capture.state.video = CaptureState::Off;
GFX_NotifyVideoCaptureStatus(false);
LOG_MSG("CAPTURE: Stopped capturing video output");
}
}
Expand Down
6 changes: 5 additions & 1 deletion src/capture/capture_audio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

#include "mem.h"
#include "setup.h"
#include "video.h"

static constexpr auto SampleFrameSize = 4;
static constexpr auto NumFramesInBuffer = 16 * 1024;
Expand Down Expand Up @@ -91,9 +92,11 @@ void capture_audio_add_data(const uint32_t sample_rate,
const int16_t* sample_frames)
{
if (!wave.handle) {
GFX_NotifyAudioCaptureStatus(true);
create_wave_file(sample_rate);
}
if (!wave.handle) {
GFX_NotifyAudioCaptureStatus(false);
return;
}

Expand Down Expand Up @@ -160,5 +163,6 @@ void capture_audio_finalise()
fclose(wave.handle);

wave = {};
}

GFX_NotifyAudioCaptureStatus(false);
}
24 changes: 13 additions & 11 deletions src/cpu/cpu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,20 @@
#include <cstddef>
#include <sstream>

#include "memory.h"
#include "debug.h"
#include "mapper.h"
#include "setup.h"
#include "programs.h"
#include "paging.h"
#include "pic.h"
#include "lazyflags.h"
#include "mapper.h"
#include "memory.h"
#include "paging.h"
#include "programs.h"
#include "setup.h"
#include "support.h"

extern void GFX_RefreshTitle(const bool is_paused = false);
extern void GFX_SetTitle(const int32_t cycles, const bool is_paused = false);
#include "video.h"

#if 1
#undef LOG
Expand Down Expand Up @@ -1597,7 +1599,7 @@ void CPU_SET_CRX(Bitu cr,Bitu value) {
CPU_CycleLeft=0;
CPU_Cycles=0;
CPU_OldCycleMax=CPU_CycleMax;
GFX_SetTitle(CPU_CyclePercUsed);
GFX_NotifyCyclesChanged(CPU_CyclePercUsed);
if(!printed_cycles_auto_info) {
printed_cycles_auto_info = true;
LOG_MSG("DOSBox has switched to max cycles, because of the setting: cycles=auto.\nIf the game runs too fast, try a fixed cycles amount in DOSBox's options.");
Expand Down Expand Up @@ -2193,7 +2195,7 @@ static void CPU_CycleIncrease(bool pressed) {
CPU_CyclePercUsed+=5;
if (CPU_CyclePercUsed>100) CPU_CyclePercUsed=100;
LOG_MSG("CPU speed: max %d percent.",CPU_CyclePercUsed);
GFX_SetTitle(CPU_CyclePercUsed);
GFX_NotifyCyclesChanged(CPU_CyclePercUsed);
} else {
int32_t old_cycles=CPU_CycleMax;
if (CPU_CycleUp < 100) {
Expand All @@ -2210,7 +2212,7 @@ static void CPU_CycleIncrease(bool pressed) {
LOG_MSG("CPU speed: fixed %d cycles. If you need more than 20000, try core=dynamic in DOSBox's options.",CPU_CycleMax);
else
LOG_MSG("CPU speed: fixed %d cycles.",CPU_CycleMax);
GFX_SetTitle(CPU_CycleMax);
GFX_NotifyCyclesChanged(CPU_CycleMax);
}
}

Expand All @@ -2223,7 +2225,7 @@ static void CPU_CycleDecrease(bool pressed) {
LOG_MSG("CPU speed: max %d percent. If the game runs too fast, try a fixed cycles amount in DOSBox's options.",CPU_CyclePercUsed);
else
LOG_MSG("CPU speed: max %d percent.",CPU_CyclePercUsed);
GFX_SetTitle(CPU_CyclePercUsed);
GFX_NotifyCyclesChanged(CPU_CyclePercUsed);
} else {
if (CPU_CycleDown < 100) {
CPU_CycleMax = (int32_t)(CPU_CycleMax /
Expand All @@ -2235,7 +2237,7 @@ static void CPU_CycleDecrease(bool pressed) {
CPU_CycleLeft=0;CPU_Cycles=0;
if (CPU_CycleMax <= 0) CPU_CycleMax=1;
LOG_MSG("CPU speed: fixed %d cycles.",CPU_CycleMax);
GFX_SetTitle(CPU_CycleMax);
GFX_NotifyCyclesChanged(CPU_CycleMax);
}
}

Expand Down Expand Up @@ -2480,9 +2482,9 @@ class CPU final : public Module_base {
if(CPU_CycleUp <= 0) CPU_CycleUp = 500;
if(CPU_CycleDown <= 0) CPU_CycleDown = 20;
if (CPU_CycleAutoAdjust) {
GFX_SetTitle(CPU_CyclePercUsed);
GFX_NotifyCyclesChanged(CPU_CyclePercUsed);
} else {
GFX_SetTitle(CPU_CycleMax);
GFX_NotifyCyclesChanged(CPU_CycleMax);
}
return true;
}
Expand Down
15 changes: 15 additions & 0 deletions src/dos/dos.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,21 @@ DOS_InfoBlock dos_infoblock;
uint16_t countryNo = 0;
unsigned int result_errorcode = 0;

static bool is_guest_booted = false;

extern void DOS_ClearLaunchedProgramNames();

void DOS_NotifyBooting()
{
is_guest_booted = true;
DOS_ClearLaunchedProgramNames();
}

bool DOS_IsGuestOsBooted()
{
return is_guest_booted;
}

#define DOS_COPYBUFSIZE 0x10000
uint8_t dos_copybuf[DOS_COPYBUFSIZE];

Expand Down
Loading

0 comments on commit 95055de

Please sign in to comment.