Skip to content
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
54 changes: 53 additions & 1 deletion Emu.yyp

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 11 additions & 11 deletions objects/obj_emu_demo/Create_0.gml
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ container.AddContent(tab_group);
#region bio
tab_bio.AddContent([
new EmuText(32, EMU_AUTO, 512, 32, "[c_blue]Character Bio[/c]"),
new EmuTextbox_H(32, EMU_AUTO, 512, 32, "Name:", data.name, "enter a name", 32, E_InputTypes.STRING, function() {
new EmuTextbox(32, EMU_AUTO, 512, 32, "Name:", data.name, "enter a name", 32, E_InputTypes.STRING, function() {
obj_emu_demo.data.name = value;
}),
new EmuTextbox_H(32, EMU_AUTO, 512, 32, "Nickname:", data.nickname, "enter a nickname", 32, E_InputTypes.STRING, function() {
new EmuTextbox(32, EMU_AUTO, 512, 32, "Nickname:", data.nickname, "enter a nickname", 32, E_InputTypes.STRING, function() {
obj_emu_demo.data.nickname = value;
}),
]);
Expand Down Expand Up @@ -119,31 +119,31 @@ tab_look.AddContent([

#region stats

var input_str = new EmuTextbox_H(32, EMU_AUTO, 512, 32, "Strength:", string(data.str), "-5 to +5", 2, E_InputTypes.INT, function() {
var input_str = new EmuTextbox(32, EMU_AUTO, 512, 32, "Strength:", string(data.str), "-5 to +5", 2, E_InputTypes.INT, function() {
obj_emu_demo.data.str = real(value);
});
input_str.SetRealNumberBounds(-5, 5);
var input_dex = new EmuTextbox_H(32, EMU_AUTO, 512, 32, "Dexterity:", string(data.dex), "-5 to +5", 2, E_InputTypes.INT, function() {
var input_dex = new EmuTextbox(32, EMU_AUTO, 512, 32, "Dexterity:", string(data.dex), "-5 to +5", 2, E_InputTypes.INT, function() {
obj_emu_demo.data.str = real(value);
});
input_dex.SetRealNumberBounds(-5, 5);
var input_con = new EmuTextbox_H(32, EMU_AUTO, 512, 32, "Constitution:", string(data.con), "-5 to +5", 2, E_InputTypes.INT, function() {
var input_con = new EmuTextbox(32, EMU_AUTO, 512, 32, "Constitution:", string(data.con), "-5 to +5", 2, E_InputTypes.INT, function() {
obj_emu_demo.data.con = real(value);
});
input_con.SetRealNumberBounds(-5, 5);
var input_int = new EmuTextbox_H(32, EMU_AUTO, 512, 32, "Intelligence:", string(data.int), "-5 to +5", 2, E_InputTypes.INT, function() {
var input_int = new EmuTextbox(32, EMU_AUTO, 512, 32, "Intelligence:", string(data.int), "-5 to +5", 2, E_InputTypes.INT, function() {
obj_emu_demo.data.int = real(value);
});
input_int.SetRealNumberBounds(-5, 5);
var input_wis = new EmuTextbox_H(32, EMU_AUTO, 512, 32, "Wisdom:", string(data.wis), "-5 to +5", 2, E_InputTypes.INT, function() {
var input_wis = new EmuTextbox(32, EMU_AUTO, 512, 32, "Wisdom:", string(data.wis), "-5 to +5", 2, E_InputTypes.INT, function() {
obj_emu_demo.data.wis = real(value);
});
input_wis.SetRealNumberBounds(-5, 5);
var input_cha = new EmuTextbox_H(32, EMU_AUTO, 512, 32, "Charisma:", string(data.cha), "-5 to +5", 2, E_InputTypes.INT, function() {
var input_cha = new EmuTextbox(32, EMU_AUTO, 512, 32, "Charisma:", string(data.cha), "-5 to +5", 2, E_InputTypes.INT, function() {
obj_emu_demo.data.cha = real(value);
});
input_cha.SetRealNumberBounds(-5, 5);
var input_level = new EmuTextbox_H(32, EMU_AUTO, 512, 32, "[#006600]Level:[/c]", string(data.level), "1 to 10", 2, E_InputTypes.INT, function() {
var input_level = new EmuTextbox(32, EMU_AUTO, 512, 32, "[#006600]Level:[/c]", string(data.level), "1 to 10", 2, E_InputTypes.INT, function() {
obj_emu_demo.data.level = real(value);
});
input_level.SetRealNumberBounds(1, 10);
Expand Down Expand Up @@ -186,7 +186,7 @@ tab_skills.AddContent([
new EmuText(320, EMU_AUTO, 256, 32, "Skill Name:"),
]);

var input_skill_name = new EmuTextbox_H(320, EMU_AUTO, 256, 32, "", "", "skill name", 32, E_InputTypes.STRING, function() {
var input_skill_name = new EmuTextbox(320, EMU_AUTO, 256, 32, "", "", "skill name", 32, E_InputTypes.STRING, function() {
var selection = list.GetSelection();
if (selection > -1) {
obj_emu_demo.data.skills[| selection] = value;
Expand All @@ -204,7 +204,7 @@ button_remove.list = list_your_skills;
#endregion

#region summary
var input_summary = new EmuTextbox_H(32, EMU_AUTO, 512, 256, "Summary:", data.summary, "up to 500 characters", 500, E_InputTypes.STRING, function() {
var input_summary = new EmuTextbox(32, EMU_AUTO, 512, 256, "Summary:", data.summary, "up to 500 characters", 500, E_InputTypes.STRING, function() {
obj_emu_demo.data.summary = value;
});
input_summary.SetMultiLine(true);
Expand Down
4 changes: 3 additions & 1 deletion scripts/EmuButton/EmuButton.gml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ function EmuButton(_x, _y, _w, _h, _text, _callback) : EmuCallback(_x, _y, _w, _
text = _text;
alignment = fa_center;
valignment = fa_middle;

_textify = function(name) {
return _emu_string_concat("var ", name, " = new EmuButton(", x, ", ", y, ", ", width, ", ", height, ", ", _emu_string_escape(text), ", function() {/* IMPLEMENT BUTTON CALLBACK HERE */});\n");
}
Render = function(base_x, base_y) {
processAdvancement();

Expand Down
4 changes: 4 additions & 0 deletions scripts/EmuButton_Image/EmuButton_Image.gml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ function EmuButtonImage(_x, _y, _w, _h, _sprite, _index, _blend, _alpha, _scale_

surface = noone;

_textify = function(name) {
return _emu_string_concat("var ", name, " = new EmuButtonImage(", x, ", ", y, ", ", width, ", ", height, ", ", sprite_get_name(sprite), ", ", index, ", ", blend, ", ", alpha, ", ", fill, ", function() {/* IMPLEMENT BUTTON CALLBACK HERE */});\n");
}

Render = function(base_x, base_y) {
processAdvancement();

Expand Down
6 changes: 5 additions & 1 deletion scripts/EmuTab/EmuTab.gml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ function EmuTab(_name) : EmuCore(0, 0, 0, 0) constructor {
header_y = 0;
header_width = 0;
header_height = 0;

_textify = function(name) {
var s = _emu_string_concat("var ", name, " = new EmuTab(", _emu_string_escape(text), ");\n");
s += _textify_recurse_contents(name);
return s;
}
Render = function(base_x, base_y) {
processAdvancement();

Expand Down
25 changes: 24 additions & 1 deletion scripts/EmuTabGroup/EmuTabGroup.gml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,30 @@ function EmuTabGroup(_x, _y, _w, _h, _rows, _row_height) : EmuCore(_x, _y, _w, _

active_tab = noone;
active_tab_request = noone;

_textify = function(name) {
var s = _emu_string_concat("var ", name, " = new EmuTabGroup(", x, ", ", y, ", ", width, ", ", height, ", ", rows, ", ", row_height, ");") + "\n";
if (rows > 0) {
for (var i = 0; i < rows; i++) {
var tab_row = contents[| i];
for (var z = 0; z < ds_list_size(tab_row.contents); z++) {
var tab = tab_row.contents[| z];
s += tab.Textify(name + "_" + string(z) + "x" + string(i));
}
}
for (var i = 0; i < rows; i++) {
s += name + ".AddTabs(" + string(i) + ", [";
var tab_row = contents[| i];
for (var z = 0; z < ds_list_size(tab_row.contents); z++) {
var tab = tab_row.contents[| z];
s += name + "_" + string(z) + "x" + string(i);
if (z < ds_list_size(tab_row.contents) - 1)
s += ", ";
}
s += "]);\n";
}
}
return s;
}
AddTabs = function(row, tabs) {
processAdvancement();

Expand Down
4 changes: 3 additions & 1 deletion scripts/EmuText/EmuText.gml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
// See the Github wiki for documentation: https://github.com/DragoniteSpam/Emu/wiki
function EmuText(_x, _y, _w, _h, _text) : EmuCore(_x, _y, _w, _h) constructor {
text = _text;

_textify = function(name) {
return _emu_string_concat("var ", name, " = new EmuText(", x, ", ", y, ", ", width, ", ", height, ", ", _emu_string_escape(text), ");\n");
}
Render = function(base_x, base_y) {
processAdvancement();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Script assets have changed for v2.3.0 see
// https://help.yoyogames.com/hc/en-us/articles/360005277377 for more information
function EmuTextbox_H(_x, _y, _w, _h, _text, _value, _help_text, _character_limit, _input_type, _callback) : EmuCallback(_x, _y, _w, _h, _value, _callback) constructor {
function EmuTextbox(_x, _y, _w, _h, _text, _value, _help_text, _character_limit, _input_type, _callback) : EmuCallback(_x, _y, _w, _h, _value, _callback) constructor {
text = _text;
help_text = _help_text;
character_limit = clamp(_character_limit, 1, 1000);
Expand All @@ -19,7 +19,9 @@ function EmuTextbox_H(_x, _y, _w, _h, _text, _value, _help_text, _character_limi

sprite_ring = spr_emu_ring
sprite_enter = spr_emu_enter;

_textify = function(name) {
return _emu_string_concat("var ", name, " = new EmuTextbox(", x, ", ", y, ", ", width, ", ", height, ", ", _emu_string_escape(text), ", ", _emu_string_escape(value), ", ", _emu_string_escape(help_text), ", ", character_limit, ", ", value_type, ", function() {/* IMPLEMENT TEXTBOX CALLBACK HERE */});\n");
}
surface = surface_create(value_x2 - value_x1, value_y2 - value_y1);

working_value = "";
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 30 additions & 1 deletion scripts/Emu_Core/Emu_Core.gml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Emu (c) 2020 @dragonitespam
// See the Github wiki for documentation: https://github.com/DragoniteSpam/Emu/wiki

function EmuCore(_x, _y, _w, _h) constructor {
x = _x;
y = _y;
Expand Down Expand Up @@ -30,7 +31,35 @@ function EmuCore(_x, _y, _w, _h) constructor {
sprite_nineslice = spr_emu_nineslice;
element_spacing_y = 16;
sprite_checkers = spr_emu_checker;

_textify_recurse_contents = function(name) {
var s = "";
if (ds_list_size(contents) > 0) {
// control initialization
for (var i = 0; i < ds_list_size(contents); i++) {
var control = contents[| i];
s += control.Textify(name + "_" + string(i));
}

// adding controls to base control
s += name + ".AddContents([";
for (var i = 0; i < ds_list_size(contents); i++) {
s += name + "_" + string(i);
if (i < ds_list_size(contents) - 1)
s += ", ";
}
s += "]);\n"
}
return s;
}
_textify = function(name) {
var s = _emu_string_concat("var ", name, " = new EmuCore(", x, ", ", y, ", ", width, ", ", height, ");") + "\n";
s += _textify_recurse_contents(name);
return s;
}
Textify = function(base_name) {
return _textify(base_name);
}

AddContent = function(elements) {
if (!is_array(elements)) {
elements = [elements];
Expand Down
27 changes: 27 additions & 0 deletions scripts/emu_init/emu_init.gml
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,31 @@ function _emu_active_element() {
}
return _active;
}
function _emu_string_escape(str) {
var s = "\"";
for (var i = 0; i < string_length(str); i++) {
var c = string_char_at(str, i + 1);
/// TODO: add support for unicode, non-ascii bytes and figure out a better way of doing this
// Best case scenario, gms2 has a function that does this by itself.
if (c == "\"") s += "\\\""
else if (c == "\\") s += "\\\\"
else if (c == "\n") s += "\\n"
else if (c == "\r") s += "\\r"
else if (c == "\b") s += "\\b"
else if (c == "\f") s += "\\f"
else if (c == "\t") s += "\\t"
else if (c == "\v") s += "\\v"
else s += c;
}
s += "\"";
return s;
}
function _emu_string_concat() {
var s = "";
for (var i = 0; i < argument_count; i++) {
var arg = argument[i];
s += string(arg);
}
return s;
}
#endregion