Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Write radio sound files from pbo to temp folder (drop b64) #978

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions addons/sys_sounds/CfgAcreSounds.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,33 @@

class CfgAcreSounds {
class Acre_GenericClickOn {
sound = "\idi\acre\addons\sys_sounds\sounds\mic_click_new_on.b64";
file = "\idi\acre\addons\sys_sounds\sounds\Acre_GenericClickOn.wav";
};
class Acre_GenericClickOff {
sound = "\idi\acre\addons\sys_sounds\sounds\mic_click_new_off.b64";
file = "\idi\acre\addons\sys_sounds\sounds\Acre_GenericClickOff.wav";
};

class Acre_GenericBeep {
sound = "\idi\acre\addons\sys_sounds\sounds\beep.b64";
file = "\idi\acre\addons\sys_sounds\sounds\Acre_GenericBeep.wav";
};
class Acre_GenericBeepLow {
sound = "\idi\acre\addons\sys_sounds\sounds\beep-low.b64";
file = "\idi\acre\addons\sys_sounds\sounds\Acre_GenericBeepLow.wav";
};

class Acre_GenericSquawkOn {
sound = "\idi\acre\addons\sys_sounds\sounds\mic_click_other_on.b64";
file = "\idi\acre\addons\sys_sounds\sounds\Acre_GenericSquawkOn.wav";
};

class Acre_GenericSquawkOff {
sound = "\idi\acre\addons\sys_sounds\sounds\mic_click_other_off.b64";
file = "\idi\acre\addons\sys_sounds\sounds\Acre_GenericSquawkOff.wav";
};

class Acre_GenericClick {
sound = "\idi\acre\addons\sys_sounds\sounds\click.b64";
file = "\idi\acre\addons\sys_sounds\sounds\Acre_GenericClick.wav";
};

// sys_sem52sl and sem70
class Acre_SEMKnob {
sound = "\idi\acre\addons\sys_sounds\sounds\semknob.b64";
file = "\idi\acre\addons\sys_sounds\sounds\Acre_SEMKnob.wav";
};
};
14 changes: 14 additions & 0 deletions addons/sys_sounds/XEH_preStart.sqf
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
#include "script_component.hpp"

#include "XEH_PREP.hpp"

if (!hasInterface) exitWith {};

INFO("Loading CfgAcreSounds");
{
private _classname = configName _x;
private _file = getText (_x >> "file");
if (_file != "") then {
private _ret = ["copy_to_temp",[_file,_classname]] call EFUNC(sys_core,callExt);
if (_ret != "") then { ERROR_2("Error loading sound [%1: %2]",_classname,_ret); };
} else {
ERROR_1("No sound file in config [%1]",_classname);
}
} forEach ("true" configClasses (configFile >> "CfgAcreSounds"));
2 changes: 2 additions & 0 deletions addons/sys_sounds/fnc_handleLoadedSound.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
* Public: No
*/

if (true) exitWith { diag_log "removed?" };

params ["_id","_okN"];

_okN = parseNumber _okN;
Expand Down
2 changes: 2 additions & 0 deletions addons/sys_sounds/fnc_loadSound.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
* Public: No
*/

if (true) exitWith { diag_log "removed?" };

params ["_className",["_returnFunction",nil],["_force",false]];

// If teamspeak is connected.
Expand Down
Binary file added addons/sys_sounds/sounds/Acre_GenericBeep.wav
Binary file not shown.
Binary file added addons/sys_sounds/sounds/Acre_GenericBeepLow.wav
Binary file not shown.
Binary file added addons/sys_sounds/sounds/Acre_GenericClick.wav
Binary file not shown.
Binary file added addons/sys_sounds/sounds/Acre_GenericClickOff.wav
Binary file not shown.
Binary file added addons/sys_sounds/sounds/Acre_GenericClickOn.wav
Binary file not shown.
Binary file not shown.
Binary file added addons/sys_sounds/sounds/Acre_GenericSquawkOn.wav
Binary file not shown.
Binary file added addons/sys_sounds/sounds/Acre_SEMKnob.wav
Binary file not shown.
55 changes: 49 additions & 6 deletions extensions/src/ACRE2Arma/common/pbo/fileloader.hpp
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
#pragma once

#include "controller.hpp"
#include "archive.hpp"
#include "search.hpp"
#include "singleton.hpp"
#include "membuf.hpp"

#include <shlwapi.h>
#pragma comment(lib, "shlwapi.lib")

namespace acre {
namespace pbo {
class file_entry {
public:
file_entry() {};
file_entry(file_p entry_) : _file(entry_) {
file_entry() = delete;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to delete. Simply delete the constructor.

Suggested change
file_entry() = delete;
file_entry() = delete;

file_entry(file_p entry_) : _file(entry_) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
file_entry(file_p entry_) : _file(entry_) {
explicit file_entry(file_p entry_) : _file(entry_) {



_memory_buffer = acre::membuf((char *)_file->data.get(), entry_->entry->storage_size);
_stream = new std::istream(&_memory_buffer);

};
~file_entry() { delete _stream; };
std::istream & stream() { return *_stream; };
Expand All @@ -39,10 +41,51 @@ namespace acre {

//@TODO: yea this is not the best way to do this...
//Initialize the fileloader before threads start eating it.
void poke() {
void poke(acre::controller * ctrl) {
ctrl->add("copy_to_temp", std::bind(&acre::pbo::fileloader::copy_to_temp, this, std::placeholders::_1, std::placeholders::_2));
return;
}

// write wav files from pbo to temp folder
bool acre::pbo::fileloader::copy_to_temp(const arguments& _args, std::string& result) {
if (_args.size() < 2) {
result = "Bad Arg count";
return false;
}
std::string source_arma_path = _args.as_string(0);
std::string output_filename = _args.as_string(1);
LOG(INFO) << "copy_to_temp [" << source_arma_path << ", " << output_filename << "]";

file_entry_p fep;
if (!get_file(source_arma_path, "wav", fep)) {
result = "File not found";
return false;
}
std::istream& arma_filesys_is(fep->stream());

char tempPath[MAX_PATH - 14];
GetTempPathA(sizeof(tempPath), tempPath);
std::string tempFolder = std::string(tempPath);
tempFolder += "acre";
if (!PathFileExistsA(tempFolder.c_str())) {
if (!CreateDirectoryA(tempFolder.c_str(), NULL)) {
result = "Could not create temp folder";
return false;
}
}
std::ofstream temp_ofs(tempFolder + "\\" + output_filename, std::ios::out | std::ios::binary | std::ios::trunc);
if (!temp_ofs.is_open()) {
result = "Could not open temp file";
return false;
}

temp_ofs << arma_filesys_is.rdbuf();
temp_ofs.close();

result = "";
return true;
}

bool get_file(std::string path_, std::string _extension, file_entry_p &entry_) {
std::string working_path = path_;
// remove leading slash
Expand Down Expand Up @@ -106,4 +149,4 @@ namespace acre {
};
};
}
}
}
2 changes: 1 addition & 1 deletion extensions/src/ACRE2Arma/controller/controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ namespace acre {
bool controller::init(const arguments &_args, std::string & result) {
if (!_initiated) {
_initiated = true;
acre::pbo::fileloader::get().poke();
acre::pbo::fileloader::get().poke(this);
add_module(std::make_shared<acre::signal::controller>());
}
return true;
Expand Down