Skip to content

Commit

Permalink
Improved Sound Debug UI, updated ImGui
Browse files Browse the repository at this point in the history
  • Loading branch information
xythobuz committed Mar 9, 2015
1 parent 09b110b commit 86a7bba
Show file tree
Hide file tree
Showing 17 changed files with 413 additions and 325 deletions.
7 changes: 7 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

## OpenRaider (0.1.3) xythobuz <xythobuz@xythobuz.de>

[ 20140309 ]
* Removed (unused) SSE support script
* Added level loading notification in main menu
* Can now start/stop individual SoundSources
* Added SoundDetail debug UI, improved SoundSources debug UI
* Updated imgui to version 1.35

[ 20140307 ]
* Can now load all TR3 levels without crashing
* Sound Sources now working, with (more or less) proper 3D Sound
Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,6 @@ There are some included cmake scripts:

* [FindALUT](https://github.com/rpavlik/cmake-modules/blob/master/FindALUT.cmake)
* [FindSDL2](https://github.com/dhewm/dhewm3/blob/master/neo/sys/cmake/FindSDL2.cmake)
* [FindSSE](https://gitorious.org/vc/vc/source/a1d8b9fc31060d870386613cc72319546c850b87:cmake/FindSSE.cmake)
* [GetGitRevisionDescription.cmake](https://github.com/rpavlik/cmake-modules/blob/master/GetGitRevisionDescription.cmake)
* [GetGitRevisionDescription.cmake.in](https://github.com/rpavlik/cmake-modules/blob/master/GetGitRevisionDescription.cmake.in)
* [FindGLM] (https://github.com/g-truc/glm/blob/master/util/FindGLM.cmake)
Expand Down
1 change: 0 additions & 1 deletion TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

## Cmake

* Support SSE with other compilers than Clang (src/CMakeLists.txt)
* Visual C++ compiler flags? (CMakeLists.txt)
* Better test integration

Expand Down
124 changes: 0 additions & 124 deletions cmake/FindSSE.cmake

This file was deleted.

2 changes: 1 addition & 1 deletion include/Menu.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class Menu {

protected:

virtual void showDialog(std::string msg, std::string btn1, std::string btn2,
virtual void showDialog(std::string msg, std::string btn1, std::string btn2 = "",
std::function<int (bool state)> callback = std::function<int (bool)>());

virtual void ackDialog();
Expand Down
6 changes: 5 additions & 1 deletion include/SoundManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,20 @@
class SoundSource {
public:
SoundSource(glm::vec3 p, int i, int f)
: pos(p), id(i), flags(f), source(-1) { }
: pos(p), id(i), flags(f), source(-1), playing(false) { }
void prepare();
void play();
void stop();
glm::vec3 getPos() { return pos; }
int getID() { return id; }
int getFlags() { return flags; }
int getSource() { return source; }
bool isPlaying() { return playing; }

private:
glm::vec3 pos;
int id, flags, source;
bool playing;
};

class SoundDetail {
Expand Down
1 change: 1 addition & 0 deletions include/system/Sound.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class Sound {
static void listenAt(glm::vec3 pos, glm::vec3 at, glm::vec3 up);

static void play(int source, bool atListener = false);
static void stop(int source);
static void stopAll();

static void setEnabled(bool on = true);
Expand Down
1 change: 1 addition & 0 deletions include/system/SoundAL.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class SoundAL {
static void listenAt(glm::vec3 pos, glm::vec3 at, glm::vec3 up);

static void play(int source, bool atListener);
static void stop(int source);
static void stopAll();

static void setEnabled(bool on);
Expand Down
30 changes: 0 additions & 30 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -170,36 +170,6 @@ endif (APPLE)

#################################################################

# Check for SSE, enable if available
include (../cmake/FindSSE.cmake)
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
if (SSE_FOUND)
set (SSE_FOUND_MSG "${SSE_FOUND_MSG} SSE")
set (OpenRaider_CXX_FLAGS "${OpenRaider_CXX_FLAGS} -msse")
endif (SSE_FOUND)
if (SSE2_FOUND)
set (SSE_FOUND_MSG "${SSE_FOUND_MSG} SSE2")
set (OpenRaider_CXX_FLAGS "${OpenRaider_CXX_FLAGS} -msse2")
endif (SSE2_FOUND)
if (SSE3_FOUND)
set (SSE_FOUND_MSG "${SSE_FOUND_MSG} SSE3")
set (OpenRaider_CXX_FLAGS "${OpenRaider_CXX_FLAGS} -msse3")
endif (SSE3_FOUND)
if (SSSE3_FOUND)
set (SSE_FOUND_MSG "${SSE_FOUND_MSG} SSSE3")
set (OpenRaider_CXX_FLAGS "${OpenRaider_CXX_FLAGS} -mssse3")
endif (SSSE3_FOUND)
if (SSE4_1_FOUND)
set (SSE_FOUND_MSG "${SSE_FOUND_MSG} SSE4.1")
set (OpenRaider_CXX_FLAGS "${OpenRaider_CXX_FLAGS} -msse4.1")
endif (SSE4_1_FOUND)

# Display message if something is enabled
if (NOT "${SSE_FOUND_MSG}" STREQUAL "")
message (STATUS "Enabled${SSE_FOUND_MSG}...")
endif (NOT "${SSE_FOUND_MSG}" STREQUAL "")
endif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")

# Apply Flags
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenRaider_CXX_FLAGS}")
set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${OpenRaider_CXX_FLAGS} ${OpenRaider_CXX_FLAGS_DEBUG}")
Expand Down
3 changes: 3 additions & 0 deletions src/MenuFolder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,11 @@ void MenuFolder::loadOrOpen() {
showDialog("Error reading subfolder!", "OK", "");
}
} else {
showDialog("Loading...", "OK");
renderFrame();
int error = Game::loadLevel(mapFolder->getFile((unsigned long)mCursor
- 1 - mapFolder->folderCount()).getPath().c_str());
ackDialog();
if (error == 0) {
visible = false;
} else {
Expand Down
101 changes: 92 additions & 9 deletions src/SoundManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,24 @@ void SoundSource::prepare() {
if (ret < 0) {
Log::get(LOG_ERROR) << "Error positioning SoundSource " << id << Log::endl;
}
Sound::play(source, false);
}
}
}

void SoundSource::play() {
playing = true;

if (source >= 0)
Sound::play(source, false);
}

void SoundSource::stop() {
playing = false;

if (source >= 0)
Sound::stop(source);
}

// ----------------------------------------------------------------------------

std::vector<SoundSource> SoundManager::soundSources;
Expand Down Expand Up @@ -69,6 +82,7 @@ int SoundManager::prepareSources() {

for (int i = 0; i < soundSources.size(); i++) {
soundSources.at(i).prepare();
soundSources.at(i).play();
}

return 0;
Expand Down Expand Up @@ -142,35 +156,104 @@ int SoundManager::playSound(int index) {
}

void SoundManager::display() {
static bool offsets = false;
if (ImGui::CollapsingHeader("Sound Sources")) {
ImGui::Columns(5, "soundsources");
ImGui::Text("No"); ImGui::NextColumn();
ImGui::Text("ID"); ImGui::NextColumn();
ImGui::Text("Flags"); ImGui::NextColumn();
ImGui::Text("Pos"); ImGui::NextColumn();
ImGui::Text("Go"); ImGui::NextColumn();
ImGui::Text("No");
ImGui::NextColumn();
ImGui::Text("ID");
ImGui::NextColumn();
ImGui::Text("Flags");
ImGui::NextColumn();
ImGui::Text("Pos");
ImGui::NextColumn();
ImGui::Text("Tools");
ImGui::NextColumn();
ImGui::Separator();
if (!offsets) {
ImGui::SetColumnOffset(1, 40.0f);
ImGui::SetColumnOffset(2, 80.0f);
ImGui::SetColumnOffset(3, 130.0f);
ImGui::SetColumnOffset(4, 350.0f);
offsets = true;
}
for (int i = 0; i < soundSources.size(); i++) {
auto& ss = soundSources.at(i);
ImGui::Text("%03d", i);
ImGui::NextColumn();
ImGui::Text("%d", ss.getID());
ImGui::NextColumn();
ImGui::Text("%X", ss.getFlags());
ImGui::Text("0x%X", ss.getFlags());
ImGui::NextColumn();
ImGui::Text("%.1f %.1f %.1f", ss.getPos().x, ss.getPos().y, ss.getPos().z);
ImGui::NextColumn();
ImGui::PushID(i);
if (ImGui::Button("Go!")) {
if (ImGui::Button("Warp")) {
Camera::setPosition(ss.getPos());
}
ImGui::SameLine();
if (ImGui::Button("Play")) {
playSound(soundSources.at(i).getID());
}
ImGui::SameLine();
if (ss.isPlaying()) {
if (ImGui::Button("Stop")) {
ss.stop();
}
} else {
if (ImGui::Button("Start")) {
ss.play();
}
}
ImGui::PopID();
ImGui::NextColumn();
}
ImGui::Columns(1);
}

static bool offsets2 = false;
if (ImGui::CollapsingHeader("Sound Details")) {
ImGui::Columns(4, "sounddetails");
ImGui::Text("No");
ImGui::NextColumn();
ImGui::Text("Vol");
ImGui::NextColumn();
ImGui::Text("Sample");
ImGui::NextColumn();
ImGui::Text("Tools");
ImGui::NextColumn();
ImGui::Separator();
if (!offsets2) {
ImGui::SetColumnOffset(1, 40.0f);
ImGui::SetColumnOffset(2, 80.0f);
ImGui::SetColumnOffset(3, 180.0f);
offsets2 = true;
}
for (int i = 0; i < soundDetails.size(); i++) {
auto& sd = soundDetails.at(i);
ImGui::Text("%03d", i);
ImGui::NextColumn();
ImGui::Text("%.2f", sd.getVolume());
ImGui::NextColumn();
if ((sd.getSample() < 0) || (sd.getSample() >= sampleIndices.size())) {
ImGui::Text("%03d --> ???", sd.getSample());
} else {
ImGui::Text("%03d --> %03d", sd.getSample(), sampleIndices.at(sd.getSample()));
}
ImGui::NextColumn();
ImGui::PushID(i);
if (sd.getSource() >= 0) {
if (ImGui::Button("Play")) {
Sound::play(sd.getSource(), true);
}
}
ImGui::PopID();
ImGui::NextColumn();
}
ImGui::Columns(1);
}

if (ImGui::CollapsingHeader("Sound Player")) {
if (ImGui::CollapsingHeader("Sound Map Player")) {
if (!Sound::getEnabled()) {
ImGui::Text("Please enable Sound first!");
if (ImGui::Button("Enable Sound!")) {
Expand Down
Loading

0 comments on commit 86a7bba

Please sign in to comment.