parent
5efa8be1c4
commit
fc8729930a
@ -0,0 +1,12 @@ |
|||||||
|
{ |
||||||
|
"sounds": { |
||||||
|
"ui_click": "assets/sounds/ui_click.ogg", |
||||||
|
"ui_hover": "assets/sounds/ui_hover.ogg", |
||||||
|
"blank": "assets/sounds/blank.ogg" |
||||||
|
}, |
||||||
|
"sprites": { |
||||||
|
}, |
||||||
|
"graphics": { |
||||||
|
"smooth_textures": false |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,10 @@ |
|||||||
|
{ |
||||||
|
"ui_shader": { |
||||||
|
"file_name": "assets/shaders/ui_shader.frag", |
||||||
|
"type": "fragment" |
||||||
|
}, |
||||||
|
"ERROR": { |
||||||
|
"file_name": "assets/shaders/ui_error.frag", |
||||||
|
"type": "fragment" |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,18 @@ |
|||||||
|
uniform vec2 u_resolution; |
||||||
|
uniform vec2 u_mouse; |
||||||
|
uniform float u_duration; |
||||||
|
uniform float u_time; |
||||||
|
uniform float u_time_end; |
||||||
|
uniform sampler2D texture; |
||||||
|
uniform bool is_shape; |
||||||
|
|
||||||
|
void main() { |
||||||
|
if(is_shape) { |
||||||
|
vec4 color = vec4(1.0, 0.0, 0.0, 1.0); |
||||||
|
gl_FragColor = gl_Color * color; |
||||||
|
} else { |
||||||
|
vec4 pixel = texture2D(texture, gl_TexCoord[0].xy); |
||||||
|
vec4 color = vec4(1.0, 0.0, 0.0, 1.0); |
||||||
|
gl_FragColor = gl_Color * color * pixel; |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,29 @@ |
|||||||
|
uniform vec2 u_resolution; |
||||||
|
uniform vec2 u_mouse; |
||||||
|
uniform float u_duration; |
||||||
|
uniform float u_time; |
||||||
|
uniform float u_time_end; |
||||||
|
uniform sampler2D texture; |
||||||
|
uniform bool is_shape; |
||||||
|
uniform bool hover; |
||||||
|
|
||||||
|
vec4 blink() { |
||||||
|
if(hover) { |
||||||
|
return vec4(0.95, 0.95, 1.0, 1.0); |
||||||
|
} else { |
||||||
|
float tick = (u_time_end - u_time) / u_duration; |
||||||
|
float blink = mix(0.5, 1.0, tick); |
||||||
|
return vec4(blink, blink, blink, 1.0); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
void main() { |
||||||
|
vec4 color = blink(); |
||||||
|
|
||||||
|
if(!is_shape) { |
||||||
|
vec4 pixel = texture2D(texture, gl_TexCoord[0].xy); |
||||||
|
color *= pixel; |
||||||
|
} |
||||||
|
|
||||||
|
gl_FragColor = gl_Color * color; |
||||||
|
} |
||||||
@ -0,0 +1,12 @@ |
|||||||
|
uniform vec2 u_resolution; |
||||||
|
uniform vec2 u_mouse; |
||||||
|
uniform float u_duration; |
||||||
|
uniform float u_time; |
||||||
|
uniform float u_time_end; |
||||||
|
|
||||||
|
void main() { |
||||||
|
float tick = (u_time_end - u_time) / u_duration; |
||||||
|
float blink = smoothstep(1.0, 0.5, tick); |
||||||
|
vec4 color = vec4(blink, blink, blink, 1.0); |
||||||
|
gl_FragColor = gl_Color * color; |
||||||
|
} |
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1 @@ |
|||||||
|
#include "code_panel.hpp" |
||||||
@ -0,0 +1 @@ |
|||||||
|
#pragma once |
||||||
@ -0,0 +1,52 @@ |
|||||||
|
#include "status_panel.hpp" |
||||||
|
#include <fmt/xchar.h> |
||||||
|
|
||||||
|
StatusPanel::StatusPanel() { |
||||||
|
$gui.position(1000, 0, 1280 - 1000, 720); |
||||||
|
$gui.layout( |
||||||
|
"[N|Reg|Stk|Key]" |
||||||
|
"[x0|r0|s0|k0]" |
||||||
|
"[x1|r1|s1|k1]" |
||||||
|
"[x2|r2|s2|k2]" |
||||||
|
"[x3|r3|s3|k3]" |
||||||
|
"[x4|r4|s4|k4]" |
||||||
|
"[x5|r5|s5|k5]" |
||||||
|
"[x6|r6|s6|k6]" |
||||||
|
"[x7|r7|s7|k7]" |
||||||
|
"[x8|r8|s8|k8]" |
||||||
|
"[x9|r9|s9|k9]" |
||||||
|
"[xA|r10|s10|k10]" |
||||||
|
"[xB|r11|s11|k11]" |
||||||
|
"[xC|r12|s12|k12]" |
||||||
|
"[xD|r13|s13|k13]" |
||||||
|
"[xE|r14|s14|k14]" |
||||||
|
"[xF|r15|s15|k15]"); |
||||||
|
} |
||||||
|
|
||||||
|
void StatusPanel::init() { |
||||||
|
for(auto& [name, cell] : $gui.cells()) { |
||||||
|
auto id = $gui.entity(name); |
||||||
|
$gui.set<guecs::Rectangle>(id, {}); |
||||||
|
$gui.set<guecs::Text>(id, {guecs::to_wstring(name)}); |
||||||
|
} |
||||||
|
|
||||||
|
$gui.init(); |
||||||
|
} |
||||||
|
|
||||||
|
void StatusPanel::render(sf::RenderTarget& window) { |
||||||
|
$gui.render(window); |
||||||
|
} |
||||||
|
|
||||||
|
void StatusPanel::update(Chip8& vm) { |
||||||
|
for(size_t i = 0; i < 16; i++) { |
||||||
|
$gui.show_text(fmt::format("r{}", i), fmt::format(L"{}", vm.registers[i])); |
||||||
|
} |
||||||
|
|
||||||
|
for(size_t i = 0; i < 16; i++) { |
||||||
|
$gui.show_text(fmt::format("s{}", i), fmt::format(L"{}", vm.stack[i])); |
||||||
|
} |
||||||
|
|
||||||
|
for(size_t i = 0; i < 16; i++) { |
||||||
|
$gui.show_text(fmt::format("k{}", i), fmt::format(L"{}", vm.keypad[i])); |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,15 @@ |
|||||||
|
#pragma once |
||||||
|
|
||||||
|
#include <guecs/sfml/components.hpp> |
||||||
|
#include <guecs/ui.hpp> |
||||||
|
#include "chip8.hpp" |
||||||
|
|
||||||
|
struct StatusPanel { |
||||||
|
guecs::UI $gui; |
||||||
|
|
||||||
|
StatusPanel(); |
||||||
|
|
||||||
|
void init(); |
||||||
|
void render(sf::RenderTarget& window); |
||||||
|
void update(Chip8& vm); |
||||||
|
}; |
||||||
Loading…
Reference in new issue