Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
PoroCYon
Bonzomatic
Commits
03875425
Commit
03875425
authored
May 18, 2017
by
Gargaj
Browse files
add config options to change window size/state before setup dialog
parent
4658d361
Changes
3
Show whitespace changes
Inline
Side-by-side
README.md
View file @
03875425
...
...
@@ -20,6 +20,11 @@ The tool was originally conceived and implemented after the Revision 2014 demosc
Create a
```config.json```
with e.g. the following contents: (all fields are optional)
```
javascript
{
"
window
"
:{
/* default window size / state, if there's a setup dialog, it will override it */
"
width
"
:
1920
,
"
height
"
:
1080
,
"
fullscreen
"
:
true
,
},
"
font
"
:{
"
file
"
:
"
Input-Regular_(InputMono-Medium).ttf
"
,
"
size
"
:
16
,
...
...
src/main.cpp
View file @
03875425
...
...
@@ -79,6 +79,20 @@ int main()
changeToAppsCurrentDirectory
();
#endif
jsonxx
::
Object
options
;
FILE
*
fConf
=
fopen
(
"config.json"
,
"rb"
);
if
(
fConf
)
{
printf
(
"Config file found, parsing...
\n
"
);
char
szConfig
[
65535
];
memset
(
szConfig
,
0
,
65535
);
int
n
=
fread
(
szConfig
,
1
,
65535
,
fConf
);
fclose
(
fConf
);
options
.
parse
(
szConfig
);
}
RENDERER_SETTINGS
settings
;
settings
.
bVsync
=
false
;
#ifdef _DEBUG
...
...
@@ -89,6 +103,15 @@ int main()
settings
.
nWidth
=
1920
;
settings
.
nHeight
=
1080
;
settings
.
windowMode
=
RENDERER_WINDOWMODE_FULLSCREEN
;
if
(
options
.
has
<
jsonxx
::
Object
>
(
"window"
))
{
if
(
options
.
get
<
jsonxx
::
Object
>
(
"window"
).
has
<
jsonxx
::
Number
>
(
"width"
))
settings
.
nWidth
=
options
.
get
<
jsonxx
::
Object
>
(
"window"
).
get
<
jsonxx
::
Number
>
(
"width"
);
if
(
options
.
get
<
jsonxx
::
Object
>
(
"window"
).
has
<
jsonxx
::
Number
>
(
"height"
))
settings
.
nHeight
=
options
.
get
<
jsonxx
::
Object
>
(
"window"
).
get
<
jsonxx
::
Number
>
(
"height"
);
if
(
options
.
get
<
jsonxx
::
Object
>
(
"window"
).
has
<
jsonxx
::
Boolean
>
(
"fullscreen"
))
settings
.
windowMode
=
options
.
get
<
jsonxx
::
Object
>
(
"window"
).
get
<
jsonxx
::
Boolean
>
(
"fullscreen"
)
?
RENDERER_WINDOWMODE_FULLSCREEN
:
RENDERER_WINDOWMODE_WINDOWED
;
}
if
(
!
Renderer
::
OpenSetupDialog
(
&
settings
))
return
-
1
;
#endif
...
...
@@ -114,63 +137,52 @@ int main()
std
::
map
<
std
::
string
,
Renderer
::
Texture
*>
textures
;
std
::
map
<
int
,
std
::
string
>
midiRoutes
;
SHADEREDITOR_OPTIONS
o
ptions
;
o
ptions
.
nFontSize
=
16
;
SHADEREDITOR_OPTIONS
editorO
ptions
;
editorO
ptions
.
nFontSize
=
16
;
#ifdef _WIN32
o
ptions
.
sFontPath
=
"c:
\\
Windows
\\
Fonts
\\
cour.ttf"
;
editorO
ptions
.
sFontPath
=
"c:
\\
Windows
\\
Fonts
\\
cour.ttf"
;
#elif __APPLE__
o
ptions
.
sFontPath
=
"/Library/Fonts/Courier New.ttf"
;
editorO
ptions
.
sFontPath
=
"/Library/Fonts/Courier New.ttf"
;
#else
// Linux case
const
std
::
string
fontPaths
[
2
]
=
{
"/usr/share/fonts/corefonts/cour.ttf"
,
"/usr/share/fonts/truetype/msttcorefonts/cour.ttf"
};
o
ptions
.
sFontPath
=
""
;
editorO
ptions
.
sFontPath
=
""
;
int
step
=
0
;
while
(
step
<
2
&&
o
ptions
.
sFontPath
.
size
()
==
0
)
{
while
(
step
<
2
&&
editorO
ptions
.
sFontPath
.
size
()
==
0
)
{
const
std
::
string
&
current
=
fontPaths
[
step
++
];
if
(
access
(
current
.
c_str
(),
R_OK
)
!=
-
1
)
{
o
ptions
.
sFontPath
=
current
;
editorO
ptions
.
sFontPath
=
current
;
}
}
assert
(
o
ptions
.
sFontPath
.
size
()
>
0
);
assert
(
editorO
ptions
.
sFontPath
.
size
()
>
0
);
#endif
o
ptions
.
nOpacity
=
0xC0
;
o
ptions
.
bUseSpacesForTabs
=
true
;
o
ptions
.
nTabSize
=
2
;
o
ptions
.
bVisibleWhitespace
=
false
;
editorO
ptions
.
nOpacity
=
0xC0
;
editorO
ptions
.
bUseSpacesForTabs
=
true
;
editorO
ptions
.
nTabSize
=
2
;
editorO
ptions
.
bVisibleWhitespace
=
false
;
int
nDebugOutputHeight
=
200
;
int
nTexPreviewWidth
=
64
;
float
fFFTSmoothingFactor
=
0.9
f
;
// higher value, smoother FFT
float
fFFTSlightSmoothingFactor
=
0.6
f
;
// higher value, smoother FFT
char
szConfig
[
65535
];
FILE
*
fConf
=
fopen
(
"config.json"
,
"rb"
);
if
(
fConf
)
if
(
!
options
.
empty
())
{
printf
(
"Config file found, parsing...
\n
"
);
memset
(
szConfig
,
0
,
65535
);
int
n
=
fread
(
szConfig
,
1
,
65535
,
fConf
);
fclose
(
fConf
);
jsonxx
::
Object
o
;
o
.
parse
(
szConfig
);
if
(
o
.
has
<
jsonxx
::
Object
>
(
"rendering"
))
if
(
options
.
has
<
jsonxx
::
Object
>
(
"rendering"
))
{
if
(
o
.
get
<
jsonxx
::
Object
>
(
"rendering"
).
has
<
jsonxx
::
Number
>
(
"fftSmoothFactor"
))
fFFTSmoothingFactor
=
o
.
get
<
jsonxx
::
Object
>
(
"rendering"
).
get
<
jsonxx
::
Number
>
(
"fftSmoothFactor"
);
if
(
o
ptions
.
get
<
jsonxx
::
Object
>
(
"rendering"
).
has
<
jsonxx
::
Number
>
(
"fftSmoothFactor"
))
fFFTSmoothingFactor
=
o
ptions
.
get
<
jsonxx
::
Object
>
(
"rendering"
).
get
<
jsonxx
::
Number
>
(
"fftSmoothFactor"
);
}
if
(
o
.
has
<
jsonxx
::
Object
>
(
"textures"
))
if
(
o
ptions
.
has
<
jsonxx
::
Object
>
(
"textures"
))
{
printf
(
"Loading textures...
\n
"
);
std
::
map
<
std
::
string
,
jsonxx
::
Value
*>
tex
=
o
.
get
<
jsonxx
::
Object
>
(
"textures"
).
kv_map
();
std
::
map
<
std
::
string
,
jsonxx
::
Value
*>
tex
=
o
ptions
.
get
<
jsonxx
::
Object
>
(
"textures"
).
kv_map
();
for
(
std
::
map
<
std
::
string
,
jsonxx
::
Value
*>::
iterator
it
=
tex
.
begin
();
it
!=
tex
.
end
();
it
++
)
{
char
*
fn
=
(
char
*
)
it
->
second
->
string_value_
->
c_str
();
...
...
@@ -184,37 +196,37 @@ int main()
textures
.
insert
(
std
::
make_pair
(
it
->
first
,
tex
)
);
}
}
if
(
o
.
has
<
jsonxx
::
Object
>
(
"font"
))
if
(
o
ptions
.
has
<
jsonxx
::
Object
>
(
"font"
))
{
if
(
o
.
get
<
jsonxx
::
Object
>
(
"font"
).
has
<
jsonxx
::
Number
>
(
"size"
))
o
ptions
.
nFontSize
=
o
.
get
<
jsonxx
::
Object
>
(
"font"
).
get
<
jsonxx
::
Number
>
(
"size"
);
if
(
o
.
get
<
jsonxx
::
Object
>
(
"font"
).
has
<
jsonxx
::
String
>
(
"file"
))
o
ptions
.
sFontPath
=
o
.
get
<
jsonxx
::
Object
>
(
"font"
).
get
<
jsonxx
::
String
>
(
"file"
);
if
(
o
ptions
.
get
<
jsonxx
::
Object
>
(
"font"
).
has
<
jsonxx
::
Number
>
(
"size"
))
editorO
ptions
.
nFontSize
=
o
ptions
.
get
<
jsonxx
::
Object
>
(
"font"
).
get
<
jsonxx
::
Number
>
(
"size"
);
if
(
o
ptions
.
get
<
jsonxx
::
Object
>
(
"font"
).
has
<
jsonxx
::
String
>
(
"file"
))
editorO
ptions
.
sFontPath
=
o
ptions
.
get
<
jsonxx
::
Object
>
(
"font"
).
get
<
jsonxx
::
String
>
(
"file"
);
}
if
(
o
.
has
<
jsonxx
::
Object
>
(
"gui"
))
if
(
o
ptions
.
has
<
jsonxx
::
Object
>
(
"gui"
))
{
if
(
o
.
get
<
jsonxx
::
Object
>
(
"gui"
).
has
<
jsonxx
::
Number
>
(
"outputHeight"
))
nDebugOutputHeight
=
o
.
get
<
jsonxx
::
Object
>
(
"gui"
).
get
<
jsonxx
::
Number
>
(
"outputHeight"
);
if
(
o
.
get
<
jsonxx
::
Object
>
(
"gui"
).
has
<
jsonxx
::
Number
>
(
"texturePreviewWidth"
))
nTexPreviewWidth
=
o
.
get
<
jsonxx
::
Object
>
(
"gui"
).
get
<
jsonxx
::
Number
>
(
"texturePreviewWidth"
);
if
(
o
.
get
<
jsonxx
::
Object
>
(
"gui"
).
has
<
jsonxx
::
Number
>
(
"opacity"
))
o
ptions
.
nOpacity
=
o
.
get
<
jsonxx
::
Object
>
(
"gui"
).
get
<
jsonxx
::
Number
>
(
"opacity"
);
if
(
o
.
get
<
jsonxx
::
Object
>
(
"gui"
).
has
<
jsonxx
::
Boolean
>
(
"spacesForTabs"
))
o
ptions
.
bUseSpacesForTabs
=
o
.
get
<
jsonxx
::
Object
>
(
"gui"
).
get
<
jsonxx
::
Boolean
>
(
"spacesForTabs"
);
if
(
o
.
get
<
jsonxx
::
Object
>
(
"gui"
).
has
<
jsonxx
::
Number
>
(
"tabSize"
))
o
ptions
.
nTabSize
=
o
.
get
<
jsonxx
::
Object
>
(
"gui"
).
get
<
jsonxx
::
Number
>
(
"tabSize"
);
if
(
o
.
get
<
jsonxx
::
Object
>
(
"gui"
).
has
<
jsonxx
::
Boolean
>
(
"visibleWhitespace"
))
o
ptions
.
bVisibleWhitespace
=
o
.
get
<
jsonxx
::
Object
>
(
"gui"
).
get
<
jsonxx
::
Boolean
>
(
"visibleWhitespace"
);
if
(
o
ptions
.
get
<
jsonxx
::
Object
>
(
"gui"
).
has
<
jsonxx
::
Number
>
(
"outputHeight"
))
nDebugOutputHeight
=
o
ptions
.
get
<
jsonxx
::
Object
>
(
"gui"
).
get
<
jsonxx
::
Number
>
(
"outputHeight"
);
if
(
o
ptions
.
get
<
jsonxx
::
Object
>
(
"gui"
).
has
<
jsonxx
::
Number
>
(
"texturePreviewWidth"
))
nTexPreviewWidth
=
o
ptions
.
get
<
jsonxx
::
Object
>
(
"gui"
).
get
<
jsonxx
::
Number
>
(
"texturePreviewWidth"
);
if
(
o
ptions
.
get
<
jsonxx
::
Object
>
(
"gui"
).
has
<
jsonxx
::
Number
>
(
"opacity"
))
editorO
ptions
.
nOpacity
=
o
ptions
.
get
<
jsonxx
::
Object
>
(
"gui"
).
get
<
jsonxx
::
Number
>
(
"opacity"
);
if
(
o
ptions
.
get
<
jsonxx
::
Object
>
(
"gui"
).
has
<
jsonxx
::
Boolean
>
(
"spacesForTabs"
))
editorO
ptions
.
bUseSpacesForTabs
=
o
ptions
.
get
<
jsonxx
::
Object
>
(
"gui"
).
get
<
jsonxx
::
Boolean
>
(
"spacesForTabs"
);
if
(
o
ptions
.
get
<
jsonxx
::
Object
>
(
"gui"
).
has
<
jsonxx
::
Number
>
(
"tabSize"
))
editorO
ptions
.
nTabSize
=
o
ptions
.
get
<
jsonxx
::
Object
>
(
"gui"
).
get
<
jsonxx
::
Number
>
(
"tabSize"
);
if
(
o
ptions
.
get
<
jsonxx
::
Object
>
(
"gui"
).
has
<
jsonxx
::
Boolean
>
(
"visibleWhitespace"
))
editorO
ptions
.
bVisibleWhitespace
=
o
ptions
.
get
<
jsonxx
::
Object
>
(
"gui"
).
get
<
jsonxx
::
Boolean
>
(
"visibleWhitespace"
);
}
if
(
o
.
has
<
jsonxx
::
Object
>
(
"midi"
))
if
(
o
ptions
.
has
<
jsonxx
::
Object
>
(
"midi"
))
{
std
::
map
<
std
::
string
,
jsonxx
::
Value
*>
tex
=
o
.
get
<
jsonxx
::
Object
>
(
"midi"
).
kv_map
();
std
::
map
<
std
::
string
,
jsonxx
::
Value
*>
tex
=
o
ptions
.
get
<
jsonxx
::
Object
>
(
"midi"
).
kv_map
();
for
(
std
::
map
<
std
::
string
,
jsonxx
::
Value
*>::
iterator
it
=
tex
.
begin
();
it
!=
tex
.
end
();
it
++
)
{
midiRoutes
.
insert
(
std
::
make_pair
(
it
->
second
->
number_value_
,
it
->
first
)
);
}
}
Capture
::
LoadSettings
(
o
);
Capture
::
LoadSettings
(
o
ptions
);
}
if
(
!
Capture
::
Open
(
settings
)
)
{
...
...
@@ -280,14 +292,14 @@ int main()
bool
bTexPreviewVisible
=
true
;
o
ptions
.
rect
=
Scintilla
::
PRectangle
(
nMargin
,
nMargin
,
settings
.
nWidth
-
nMargin
-
nTexPreviewWidth
-
nMargin
,
settings
.
nHeight
-
nMargin
*
2
-
nDebugOutputHeight
);
editorO
ptions
.
rect
=
Scintilla
::
PRectangle
(
nMargin
,
nMargin
,
settings
.
nWidth
-
nMargin
-
nTexPreviewWidth
-
nMargin
,
settings
.
nHeight
-
nMargin
*
2
-
nDebugOutputHeight
);
ShaderEditor
mShaderEditor
(
surface
);
mShaderEditor
.
Initialise
(
o
ptions
);
mShaderEditor
.
Initialise
(
editorO
ptions
);
mShaderEditor
.
SetText
(
szShader
);
o
ptions
.
rect
=
Scintilla
::
PRectangle
(
nMargin
,
settings
.
nHeight
-
nMargin
-
nDebugOutputHeight
,
settings
.
nWidth
-
nMargin
-
nTexPreviewWidth
-
nMargin
,
settings
.
nHeight
-
nMargin
);
editorO
ptions
.
rect
=
Scintilla
::
PRectangle
(
nMargin
,
settings
.
nHeight
-
nMargin
-
nDebugOutputHeight
,
settings
.
nWidth
-
nMargin
-
nTexPreviewWidth
-
nMargin
,
settings
.
nHeight
-
nMargin
);
ShaderEditor
mDebugOutput
(
surface
);
mDebugOutput
.
Initialise
(
o
ptions
);
mDebugOutput
.
Initialise
(
editorO
ptions
);
mDebugOutput
.
SetText
(
""
);
mDebugOutput
.
SetReadOnly
(
true
);
...
...
src/platform_w32_common/SetupDialog.cpp
View file @
03875425
...
...
@@ -79,7 +79,12 @@ public:
_sntprintf
(
s
,
50
,
_T
(
"%d * %d"
),
gaResolutions
[
i
].
nWidth
,
gaResolutions
[
i
].
nHeight
);
SendDlgItemMessage
(
hWnd
,
IDC_RESOLUTION
,
CB_ADDSTRING
,
0
,
(
LPARAM
)
s
);
if
(
gaResolutions
[
i
].
nWidth
==
GetSystemMetrics
(
SM_CXSCREEN
)
&&
gaResolutions
[
i
].
nHeight
==
GetSystemMetrics
(
SM_CYSCREEN
))
if
(
gaResolutions
[
i
].
nWidth
==
setup
->
nWidth
&&
gaResolutions
[
i
].
nHeight
==
setup
->
nHeight
)
{
SendDlgItemMessage
(
hWnd
,
IDC_RESOLUTION
,
CB_SETCURSEL
,
i
,
0
);
bFoundBest
=
true
;
}
if
(
!
bFoundBest
&&
gaResolutions
[
i
].
nWidth
==
GetSystemMetrics
(
SM_CXSCREEN
)
&&
gaResolutions
[
i
].
nHeight
==
GetSystemMetrics
(
SM_CYSCREEN
))
{
SendDlgItemMessage
(
hWnd
,
IDC_RESOLUTION
,
CB_SETCURSEL
,
i
,
0
);
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment