-
Notifications
You must be signed in to change notification settings - Fork 149
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
add optional pbo to load settings from userconfig file #450
Merged
Killswitch00
merged 4 commits into
master
from
optional-file-to-load-userconfig-settings
Aug 6, 2016
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
f5da218
add optional pbo to load settings from userconfig file
commy2 a28ff0c
improve logging in case file is not present
commy2 391895e
fix undefined function calls
commy2 b21acec
Merge remote-tracking branch 'origin/master' into optional-file-to-lo…
commy2 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
x\cba\addons\auto_load_settings_file |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
|
||
class Extended_PreInit_EventHandlers { | ||
class ADDON { | ||
init = QUOTE(call COMPILE_FILE(XEH_preInit)); | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#include "script_component.hpp" | ||
|
||
ADDON = false; | ||
|
||
// frame after preInit, but before postInit | ||
0 spawn { | ||
{ | ||
#include "loadSettingsFile.sqf" | ||
} call CBA_fnc_directCall; | ||
}; | ||
|
||
ADDON = true; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#include "script_component.hpp" | ||
|
||
class CfgPatches { | ||
class ADDON { | ||
author = "$STR_CBA_Author"; | ||
name = ECSTRING(settings,component); | ||
url = "$STR_CBA_URL"; | ||
units[] = {}; | ||
weapons[] = {}; | ||
requiredVersion = REQUIRED_VERSION; | ||
requiredAddons[] = {"cba_settings"}; | ||
version = VERSION; | ||
authors[] = {"commy2"}; | ||
}; | ||
}; | ||
|
||
#include "CfgEventHandlers.hpp" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
|
||
if (isFilePatchingEnabled) then { | ||
private _source = ["client", "server"] select (isMultiplayer && isServer); | ||
private _file = loadFile PATH_SETTINGS_FILE; | ||
|
||
if (_file != "") then { | ||
[_file, _source] call EFUNC(settings,import); | ||
diag_log text "[CBA] (settings): Settings file loaded."; | ||
} else { | ||
diag_log text "[CBA] (settings): Settings file not loaded. File empty or does not exist."; | ||
}; | ||
} else { | ||
diag_log text "[CBA] (settings): Cannot load settings file. File patching disabled. Use -filePatching flag."; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#define COMPONENT auto_load_settings_file | ||
#include "\x\cba\addons\main\script_mod.hpp" | ||
|
||
//#define DEBUG_ENABLED_AUTO_LOAD_SETTINGS_FILE | ||
|
||
#ifdef DEBUG_ENABLED_AUTO_LOAD_SETTINGS_FILE | ||
#define DEBUG_MODE_FULL | ||
#endif | ||
|
||
#ifdef DEBUG_SETTINGS_AUTO_LOAD_SETTINGS_FILE | ||
#define DEBUG_SETTINGS DEBUG_SETTINGS_AUTO_LOAD_SETTINGS_FILE | ||
#endif | ||
|
||
#include "\x\cba\addons\main\script_macros.hpp" | ||
|
||
#define PATH_SETTINGS_FILE "userconfig\cba\settings.sqf" |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it would be safer and cleaner to have cba launch an event when preInit finishes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks about as safe and clean as it gets - only depends on
directCall
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would've used
CBA_fnc_execNextFrame
, but theEachFrame
handler that does that is installed at postInit - many frames after preInit.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a long shot, but maybe some other mod could conceivably clog the scheduler during preinit, preventing this from running before postInit.