Pixel-Composer/scripts/panel_globalvar/panel_globalvar.gml

61 lines
1.8 KiB
Plaintext
Raw Normal View History

2023-03-19 09:17:39 +01:00
function Panel_Globalvar() : PanelContent() constructor {
2023-06-04 18:28:29 +02:00
title = __txtx("panel_globalvar", "Global Variables");
2023-03-19 09:17:39 +01:00
context_str = "Globalvar";
showHeader = false;
title_height = 64;
padding = 24;
w = ui(320);
h = ui(480);
globalvar_viewer_init();
drawWidgetInit();
function onResize() {
PANEL_PADDING
contentPane.resize(w - ui(padding + padding), h - ui(title_height + padding));
}
contentPane = new scrollPane(w - ui(padding + padding), h - ui(title_height + padding), function(_y, _m) {
var _hover = pHOVER && contentPane.hover;
draw_clear_alpha(COLORS.panel_bg_clear, 0);
var hh = 0;
var yy = _y;
var gvh = globalvar_viewer_draw(0, yy, contentPane.surface_w, _m, pFOCUS, _hover, contentPane, x + ui(padding), y + ui(title_height));
yy += gvh + ui(8);
hh += gvh + ui(8);
return hh;
});
function drawContent(panel) {
2023-06-10 13:59:45 +02:00
draw_clear_alpha(COLORS.panel_bg_clear, 0);
2023-03-19 09:17:39 +01:00
PANEL_PADDING
PANEL_TITLE
var px = ui(padding);
var py = ui(title_height);
var pw = w - ui(padding + padding);
var ph = h - ui(title_height + padding);
draw_sprite_stretched(THEME.ui_panel_bg, !in_dialog, px - ui(8), py - ui(8), pw + ui(16), ph + ui(16));
2023-06-21 20:36:53 +02:00
contentPane.setFocusHover(pFOCUS, pHOVER);
2023-03-19 09:17:39 +01:00
contentPane.draw(px, py, mx - px, my - py);
var bx = w - ui(32 + 16);
var by = title_height / 2 - ui(16 + !in_dialog * 2);
2023-06-04 18:28:29 +02:00
if(buttonInstant(THEME.button_hide, bx, by, ui(32), ui(32), [mx, my], pFOCUS, pHOVER, __txtx("panel_globalvar_add", "Add variable"), THEME.add, 1, COLORS._main_value_positive) == 2)
2023-03-19 09:17:39 +01:00
GLOBAL.createValue();
bx -= ui(32 + 4);
2023-06-04 18:28:29 +02:00
if(buttonInstant(THEME.button_hide, bx, by, ui(32), ui(32), [mx, my], pFOCUS, pHOVER, __txt("Edit"), var_editing? THEME.accept : THEME.gear,,,, 0.9) == 2)
2023-03-19 09:17:39 +01:00
var_editing = !var_editing;
}
}