Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
luciusDXL committed Sep 27, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
2 parents 03985ae + 0cd3b48 commit c0651a9
Showing 25 changed files with 226 additions and 614 deletions.
20 changes: 10 additions & 10 deletions TheForceEngine/Captions/subtitles-de.txt
Original file line number Diff line number Diff line change
@@ -20,9 +20,9 @@ m16moc01.voc "Offizier Mohc: Es ist lange her, seit ich einen Mann zum Kampf her
//SFX
boba-1.voc "[Fett lacht]"
boba-3.voc "[Fett grunzt]"
boba-4.voc "[Fett Todesschrei]"
boba-4.voc "[Fetts Todesschrei]"
beep-01.voc "[Alarm]"
beep-10.voc "[MIENE PIPST]"
beep-10.voc "[MINE PIEPST]"
fall.voc "[Kyle schreit]"
door.voc "[Türe zischt]"
door-04.voc "[Türe bewegt sich]"
@@ -75,11 +75,11 @@ m05jan01.voc "Jan: Alles klar Kyle, bin unterwegs."
m05kyl03.voc "Kyle: Wenn das Ding einen Hinweis darauf ist, womit wir es zu tun bekommen, dann brauchen wir mehr Feuerkraft."
//M06 (Detention Center)
m06kyl01.voc "Kyle: Okay Jan, ich habe Madine befreit."
m06jan01.voc "Jan: Beil dich, wir müssen zusehen das wir von hier verschwinden, bevor noch mehr Sturmtruppen eintreffen "
//M07 (Ramsees Head)
m06jan01.voc "Jan: Beeil dich, wir müssen zusehen dass wir von hier verschwinden, bevor noch mehr Sturmtruppen eintreffen "
//M07 (Ramsees Hed)
m07kyl01.voc "Kyle: Der Signalgeber ist platziert."
m07jan01.voc "Jan: Ich empfange das Signal. Sieht so aus, als wären wir hier fertig."
m07jan02.voc "Jan: OK dann lass uns mal sehen, wohin diese Schmuggler hinfliegen."
m07jan02.voc "Jan: OK dann lass uns mal sehen, wo diese Schmuggler hinfliegen."
//M08 (Robotics Facility)
m08kyl01.voc "Kyle: Erste Ladung scharf gemacht."
m08kyl02.voc "Kyle: Zweite Ladung scharf gemacht."
@@ -119,8 +119,8 @@ m13kyl01.voc "Kyle: Es geht los!"
m16kyl01.voc "Kyle: Das war die Erste..."
m16kyl02.voc "Kyle: Das ist die Zweite..."
m16kyl03.voc "Kyle: Jetzt noch die Letzte."
m16kyl04.voc "Kyle: Jan würde stolz auf mich sein."
m16kyl05.voc "Kyle: Es gibt keine Ehre im Krieg Mhoc."
m16kyl04.voc "Kyle: Jan wäre stolz auf mich."
m16kyl05.voc "Kyle: Es gibt keine Ehre im Krieg, Mohc."
m16kyl06.voc "Kyle: Für die Freiheit."

//----- CUTSCENES -----------------------------------------------
@@ -149,10 +149,10 @@ m01mma02 "Vor fünf Tagen hat das Imperium einen unserer geheimen Stützpunkte a
m01mma03 "Tak Base wurde innerhalb von Minuten zerstört. Viele unschuldige Stadtbewohner hat es genauso getroffen wie unsere eigenen Leute. Der Geheimdienst vermutet, dass es sich dabei um eine Art Vergeltung für die Vernichtung des Todesstern handelte." 12.5
m01reb01 "Ist da draussen jemand der uns hört? Dies ist Tak Base. Bitte wir werden angegriffen! Sie sind überall! Wir wurde vollkommen überrascht!" //unused
m01reb02 "Total Zerstörung! Sie brechen durch unsere Schilde... Sie brechen durch unsere Schilde!" //unused
distress "Ist da jemand draussen der uns hört? Dies ist Tak Base. Bitte, [Unterbruch] wir werden angegriffen! Sie sind überall! Wir wurden [Unterbruch] vollkommen überrascht! Total Zerstörung! Sie brechen durch unsere [Unterbruch] Schilde... Sie brechen durch unsere Schilde!"
distress "Ist da jemand draussen der uns hört? Dies ist Tak Base. Bitte, [Störung] wir werden angegriffen! Sie sind überall! Wir wurden [Störung] vollkommen überrascht! Totale Zerstörung! Sie brechen durch unsere [Störung] Schilde... Sie brechen durch unsere Schilde!"
m01kyl02 "Interessant. Abgesehen von diesen Geräuschen macht es den Anschein eines normalen imperialen Angriffs."
m01mma04 "Sehr richtig Commander. Ich hoffe Sie werden verstehen was wir hier besprechen vertraulich ist." 5.0
m01mma05 "Dieser imperiale Offizier, Crix Madine, möchte zur Allianz überlaufen. Er hat uns mit Informationen über die Entwicklung einer neuen imperialen Waffe versorgt. Wir glauben, dass diese Geräusche die Sie gerade gehört haben, von dieser Waffe stammen. Einen neuen Typ von Sturmtruppler, dem Dark Trooper." 17.3
m01mma04 "Sehr richtig Commander. Ich hoffe Sie werden verstehen dass alles was wir hier besprechen vertraulich ist." 5.0
m01mma05 "Dieser imperiale Offizier, Crix Madine, möchte zur Allianz überlaufen. Er hat uns mit Informationen über die Entwicklung einer neuen imperialen Waffe versorgt. Wir glauben, dass diese Geräusche die Sie gerade gehört haben, von dieser Waffe stammen. Einem neuen Typ von Sturmtruppler, dem Dark Trooper." 17.3
m01kyl03 "Ein neuer Sturmtruppler der eine Rebellenbasis derartig schnell ausschalten kann? Ich hätte besser weiter für das Imperium arbeiten sollen."
m01mma06 "Die Rebellenführung nimmt diese Angelegenheit nicht auf die leichte Schulter. Sie hat veranlasst Sie zu beauftragen herauszufinden ob eine Bedrohung besteht und gegebenenfalls auszuschalten. Das heisst falls Sie noch auf unserer Seite stehen." 12.5
m01kyl04 "Klingt interessant... [lange Pause] Okay ich bin dabei. Aber ich brauche dennoch Unterstützung bei diesem Auftrag. Ich möchte das Jan Ors mein Missionsoffizier ist."
61 changes: 37 additions & 24 deletions TheForceEngine/TFE_A11y/accessibility.cpp
Original file line number Diff line number Diff line change
@@ -33,7 +33,7 @@ namespace TFE_A11Y // a11y is industry slang for accessibility
bool filterCaptionFile(const string fileName);
void onFileError(const string path);
void enqueueCaption(const ConsoleArgList& args);
void drawCaptions(std::vector<Caption>* captions);
Vec2f drawCaptions(std::vector<Caption>* captions);
string toUpper(string input);
string toLower(string input);
string toFileName(string language);
@@ -47,7 +47,6 @@ namespace TFE_A11Y // a11y is industry slang for accessibility
///////////////////////////////////////////
const char* DEFAULT_FONT = "Fonts/NotoSans-Regular.ttf";
const f32 MAX_CAPTION_WIDTH = 1200;
const f32 DEFAULT_LINE_HEIGHT = 20;
const f32 LINE_PADDING = 5;
// Base duration of a caption
const s64 BASE_DURATION_MICROSECONDS = secondsToMicroseconds(0.9f);
@@ -65,7 +64,7 @@ namespace TFE_A11Y // a11y is industry slang for accessibility
///////////////////////////////////////////
// Static vars
///////////////////////////////////////////
static A11yStatus s_status = CC_NOT_LOADED;
static A11yStatus s_captionsStatus = CC_NOT_LOADED;
static FilePathList s_captionFileList;
static FilePathList s_fontFileList;
static FilePath s_currentCaptionFile;
@@ -74,7 +73,7 @@ namespace TFE_A11Y // a11y is industry slang for accessibility
static DisplayInfo s_display;
static u32 s_screenWidth;
static u32 s_screenHeight;
static bool s_active = true;
static bool s_active = true; // Used by ImGui
static bool s_logSFXNames = false;
static system_clock::duration s_lastTime;

@@ -88,10 +87,19 @@ namespace TFE_A11Y // a11y is industry slang for accessibility
static ImFont* s_currentCaptionFont;
static string s_pendingFontPath;

// Initialize the Accessibility system. Only call this once on application launch.
void init()
{
assert(s_status == CC_NOT_LOADED);
if (TFE_Settings::getA11ySettings()->captionSystemEnabled())
{
initCaptions();
}
}

void initCaptions()
{
TFE_System::logWrite(LOG_MSG, "a11y", "Initializing caption system...");

assert(s_captionsStatus == CC_NOT_LOADED);
CCMD("showCaption", enqueueCaption, 1, "Display a test caption. Example: showCaption \"Hello, world\"");
CVAR_BOOL(s_logSFXNames, "d_logSFXNames", CVFLAG_DO_NOT_SERIALIZE, "If enabled, log the name of each sound effect that plays.");

@@ -146,7 +154,9 @@ namespace TFE_A11Y // a11y is industry slang for accessibility

// Try to load the previously selected font.
string lastFontPath = TFE_Settings::getA11ySettings()->lastFontPath;
tryLoadFont(lastFontPath, false);

if (lastFontPath, ImGui::GetIO().Fonts->Locked) { setPendingFont(lastFontPath); }
else { tryLoadFont(lastFontPath, false); }
}

// Specify a font to load after ImGui finishes rendering.
@@ -226,14 +236,14 @@ namespace TFE_A11Y // a11y is industry slang for accessibility
// Captions
//////////////////////////////////////////////////////

A11yStatus getCaptionSystemStatus() { return s_captionsStatus; }

// Get the list of all caption files we detect in the Captions directories.
FilePathList getCaptionFiles() { return s_captionFileList; }

// The name and path of the currently selected Caption file
FilePath getCurrentCaptionFile() { return s_currentCaptionFile; }

A11yStatus getStatus() { return s_status; }

// Get all caption file names from the Captions directories; we will use this to populate the
// dropdown in the Accessibility settings menu.
void findCaptionFiles()
@@ -267,7 +277,7 @@ namespace TFE_A11Y // a11y is industry slang for accessibility
}

// If the language didn't load, default to English.
if (s_status != CC_LOADED)
if (s_captionsStatus != CC_LOADED)
{
string fileName = programCaptionsDir + toFileName("en");
loadCaptions(fileName);
@@ -353,15 +363,15 @@ namespace TFE_A11Y // a11y is industry slang for accessibility
s_captionMap[name] = caption;
};

s_status = CC_LOADED;
delete s_captionsBuffer;
s_captionsStatus = CC_LOADED;
free(s_captionsBuffer);
}

void onFileError(const string path)
{
string error = "Couldn't find caption file at " + path;
TFE_System::logWrite(LOG_ERROR, "a11y", error.c_str());
s_status = CC_ERROR;
s_captionsStatus = CC_ERROR;
// TODO: display an error dialog
}

@@ -403,11 +413,11 @@ namespace TFE_A11Y // a11y is industry slang for accessibility
f32 fontScale;
auto windowSize = calcWindowSize(&fontScale, env);
assert(fontScale > 0);
s32 count = 1;
size_t idx = 0;

size_t idx = 0; // Index of current character in string.
string line = ""; // Current line of the current chunk.
string chunk;
s32 chunkLineCount = 0;
string line = "";
while (idx < caption.text.length())
{
// Extend the line one character at a time until we exceed the width of the panel
@@ -431,8 +441,8 @@ namespace TFE_A11Y // a11y is industry slang for accessibility
}
else { break; }

// If the chunk has three lines, add it as a new caption.
if (chunkLineCount >= 3)
// If the chunk has reached the maximum number of lines, add it as a new caption.
if (chunkLineCount >= maxLines)
{
s32 length = (s32)chunk.length();
f32 ratio = length / (f32)caption.text.length();
@@ -450,7 +460,6 @@ namespace TFE_A11Y // a11y is industry slang for accessibility
else { break; }

caption.microsecondsRemaining -= next.microsecondsRemaining;
count++;
idx = 0;
chunkLineCount = 0;
chunk = "";
@@ -491,15 +500,15 @@ namespace TFE_A11Y // a11y is industry slang for accessibility
//TFE_System::logWrite(LOG_ERROR, "a11y", std::to_string(active.size()).c_str());
}

void drawCaptions()
Vec2f drawCaptions()
{
if (s_activeCaptions.size() > 0)
{
drawCaptions(&s_activeCaptions);
return drawCaptions(&s_activeCaptions);
}
}

void drawCaptions(std::vector<Caption>* captions)
Vec2f drawCaptions(std::vector<Caption>* captions)
{
if (isFontLoaded()) { ImGui::PushFont(s_currentCaptionFont); }

@@ -604,23 +613,27 @@ namespace TFE_A11Y // a11y is industry slang for accessibility
}
}
}

ImVec2 finalWindowSize = ImGui::GetWindowSize();
ImGui::PopStyleColor();
ImGui::End();

if (isFontLoaded()) { ImGui::PopFont(); }

s_lastTime = time;

return { finalWindowSize.x, finalWindowSize.y };
}

void drawExampleCaptions()
Vec2f drawExampleCaptions()
{
if (s_exampleCaptions.size() == 0)
{
Caption caption = s_captionMap["example_cutscene"]; // Copy
caption.env = CC_CUTSCENE;
s_exampleCaptions.push_back(caption);
}
drawCaptions(&s_exampleCaptions);
return drawCaptions(&s_exampleCaptions);
}

bool cutsceneCaptionsEnabled()
12 changes: 9 additions & 3 deletions TheForceEngine/TFE_A11y/accessibility.h
Original file line number Diff line number Diff line change
@@ -37,12 +37,18 @@ namespace TFE_A11Y {
///////////////////////////////////////////
const string FILE_NAME_START = "subtitles-";
const string FILE_NAME_EXT = ".txt";
const f32 DEFAULT_LINE_HEIGHT = 20;

///////////////////////////////////////////
// Functions
///////////////////////////////////////////

// Initialize the A11y system.
void init();

// Initialize the caption system. Only call this if the current status is CC_NOT_LOADED.
void initCaptions();

// Fonts
FilePathList getFontFiles();
FilePath getCurrentFontFile();
@@ -53,11 +59,11 @@ namespace TFE_A11Y {
// Captions
FilePathList getCaptionFiles();
FilePath getCurrentCaptionFile();
A11yStatus getStatus();
A11yStatus getCaptionSystemStatus();
void loadCaptions(const string path);
void clearActiveCaptions();
void drawCaptions();
void drawExampleCaptions();
Vec2f drawCaptions();
Vec2f drawExampleCaptions();
void focusCaptions();
void enqueueCaption(Caption caption);
void onSoundPlay(char* name, CaptionEnv env);
27 changes: 0 additions & 27 deletions TheForceEngine/TFE_Audio/audioDevice.h
Original file line number Diff line number Diff line change
@@ -4,33 +4,6 @@
#include "audioOutput.h"
#include <string>

#ifdef _WIN32
#define WIN32_LEAN_AND_MEAN 1
#include <Windows.h>

#define MUTEX_INITIALIZE(A) InitializeCriticalSection(A)
#define MUTEX_DESTROY(A) DeleteCriticalSection(A)
#define MUTEX_LOCK(A) EnterCriticalSection(A)
#define MUTEX_TRYLOCK(A) TryEnterCriticalSection(A)
#define MUTEX_UNLOCK(A) LeaveCriticalSection(A)

typedef CRITICAL_SECTION Mutex;
#undef min
#undef max
#else
#include <cstddef>

#include <pthread.h>

#define MUTEX_INITIALIZE(A) pthread_mutex_init(A, NULL)
#define MUTEX_DESTROY(A) pthread_mutex_destroy(A)
#define MUTEX_LOCK(A) pthread_mutex_lock(A)
#define MUTEX_TRYLOCK(A) pthread_mutex_trylock(A)
#define MUTEX_UNLOCK(A) pthread_mutex_unlock(A)

typedef pthread_mutex_t Mutex;
#endif

static const u32 AUDIO_STATUS_INPUT_OVERFLOW = 0x1; // Input data was discarded because of an overflow condition at the driver.
static const u32 AUDIO_STATUS_OUTPUT_UNDERFLOW = 0x2; // The output buffer ran low, likely causing a gap in the output sound.

Loading

0 comments on commit c0651a9

Please sign in to comment.