Initial Ukuvota native prototype
This commit is contained in:
commit
ce6771a541
7 files changed
+1141
No files matched your search
+11
@@ -0,0 +1,11 @@
|
||||
build/
|
||||
assets/fonts/
|
||||
result
|
||||
result-*
|
||||
*.o
|
||||
*.a
|
||||
*.so
|
||||
*.dylib
|
||||
*.dll
|
||||
*.exe
|
||||
.direnv/
|
||||
@@ -0,0 +1,109 @@
|
||||
.DEFAULT_GOAL := all
|
||||
|
||||
CC = gcc
|
||||
|
||||
UNAME_S := $(shell uname -s)
|
||||
UNAME_M := $(shell uname -m)
|
||||
|
||||
ifeq ($(UNAME_S),Linux)
|
||||
PLATFORM := linux
|
||||
else
|
||||
PLATFORM := unknown
|
||||
endif
|
||||
|
||||
ifeq ($(UNAME_M),x86_64)
|
||||
ARCH := x86_64
|
||||
else ifeq ($(UNAME_M),aarch64)
|
||||
ARCH := aarch64
|
||||
else
|
||||
ARCH := $(UNAME_M)
|
||||
endif
|
||||
|
||||
BUILD_DIR := build
|
||||
LINUX_BUILD_DIR := $(BUILD_DIR)/linux
|
||||
TARGET := $(LINUX_BUILD_DIR)/uku-$(PLATFORM)-$(ARCH)
|
||||
PACKAGE_ID := xyz.waozi.uku
|
||||
|
||||
SRC := src/main.c
|
||||
FLINT_DIR := ../flint
|
||||
FLINT_SRCS := $(wildcard $(FLINT_DIR)/src/*.c)
|
||||
RAYLIB_DIR := ../inbe/vendor/raylib/src
|
||||
RAYLIB_BUILD_DIR := ../inbe/vendor/raylib/build/sdl
|
||||
RAYLIB_A := $(RAYLIB_BUILD_DIR)/libraylib.a
|
||||
RAYLIB_SOURCES := $(wildcard $(RAYLIB_DIR)/*.c) $(wildcard $(RAYLIB_DIR)/*.h)
|
||||
LOCALE_FILES := $(wildcard locales/*.txt)
|
||||
FONT_OUTPUTS := assets/fonts/locales.png assets/fonts/locales.dat
|
||||
FONT_TOOL := ../otfchop/otfchop
|
||||
FONT_SOURCE := ../otfchop/unifont-17.0.04.otf
|
||||
|
||||
UKU_RAYLIB_CONFIG := $(RAY_RAYLIB_CONFIG) -DSUPPORT_MODULE_RAUDIO=0
|
||||
CFLAGS := -Wall -Wextra -std=c99 -Os -D_DEFAULT_SOURCE -D_GNU_SOURCE -ffunction-sections -fdata-sections
|
||||
LDFLAGS := -Wl,--gc-sections -s
|
||||
|
||||
ifeq ($(strip $(RAY_CFLAGS)),)
|
||||
$(error RAY_CFLAGS is not set. Enter the ray flake shell with 'nix develop')
|
||||
endif
|
||||
ifeq ($(strip $(RAY_LDLIBS)),)
|
||||
$(error RAY_LDLIBS is not set. Enter the ray flake shell with 'nix develop')
|
||||
endif
|
||||
ifeq ($(strip $(RAY_SDL_LDLIBS)),)
|
||||
$(error RAY_SDL_LDLIBS is not set. Enter the ray flake shell with 'nix develop')
|
||||
endif
|
||||
ifeq ($(strip $(RAY_SDL_INCLUDE_DIR)),)
|
||||
$(error RAY_SDL_INCLUDE_DIR is not set. Enter the ray flake shell with 'nix develop')
|
||||
endif
|
||||
ifeq ($(strip $(RAY_RAYLIB_CONFIG)),)
|
||||
$(error RAY_RAYLIB_CONFIG is not set. Enter the ray flake shell with 'nix develop')
|
||||
endif
|
||||
|
||||
all: native
|
||||
|
||||
native: $(TARGET)
|
||||
|
||||
$(LINUX_BUILD_DIR):
|
||||
mkdir -p $@
|
||||
|
||||
assets/fonts:
|
||||
mkdir -p $@
|
||||
|
||||
$(FONT_OUTPUTS): $(LOCALE_FILES) $(FONT_TOOL) | assets/fonts
|
||||
$(FONT_TOOL) $(FONT_SOURCE) $(LOCALE_FILES) assets/fonts/locales
|
||||
|
||||
$(FONT_TOOL): ../otfchop/otfchop.c ../otfchop/stb_truetype.h ../otfchop/stb_image_write.h
|
||||
$(MAKE) -C ../otfchop otfchop
|
||||
|
||||
$(RAYLIB_BUILD_DIR):
|
||||
mkdir -p $@
|
||||
|
||||
$(RAYLIB_A): $(RAYLIB_SOURCES) | $(RAYLIB_BUILD_DIR)
|
||||
$(MAKE) -j1 -C $(RAYLIB_DIR) \
|
||||
PLATFORM=PLATFORM_DESKTOP_SDL \
|
||||
GRAPHICS=GRAPHICS_API_OPENGL_ES2 \
|
||||
RAYLIB_LIBTYPE=STATIC \
|
||||
RAYLIB_RELEASE_PATH=../build/sdl \
|
||||
RAYLIB_MODULE_AUDIO=FALSE \
|
||||
RAYLIB_MODULE_MODELS=FALSE \
|
||||
SDL_INCLUDE_PATH="$(RAY_SDL_INCLUDE_DIR)" \
|
||||
SDL_LIBRARIES="$(RAY_SDL_LDLIBS)" \
|
||||
CUSTOM_CFLAGS="-DUSING_SDL2_PROJECT $(RAY_CFLAGS) $(UKU_RAYLIB_CONFIG) -Os -ffunction-sections -fdata-sections"
|
||||
|
||||
$(TARGET): $(SRC) $(FLINT_SRCS) $(FONT_OUTPUTS) $(RAYLIB_A) | $(LINUX_BUILD_DIR)
|
||||
$(CC) $(CFLAGS) \
|
||||
-I$(RAYLIB_DIR) \
|
||||
-I$(FLINT_DIR)/include \
|
||||
$(RAY_CFLAGS) \
|
||||
-o $@ \
|
||||
$(SRC) \
|
||||
$(FLINT_SRCS) \
|
||||
$(RAYLIB_A) \
|
||||
$(RAY_LDLIBS) \
|
||||
-lm -lpthread -ldl -lrt \
|
||||
$(LDFLAGS)
|
||||
|
||||
run: $(TARGET)
|
||||
./$(TARGET)
|
||||
|
||||
clean:
|
||||
rm -rf $(BUILD_DIR) assets/fonts
|
||||
|
||||
.PHONY: all native run clean
|
||||
@@ -0,0 +1,11 @@
|
||||
# Uku
|
||||
|
||||
Native Ukuvota prototype using Raylib and Flint.
|
||||
|
||||
Build it from its Nix shell:
|
||||
|
||||
```sh
|
||||
nix develop path:.
|
||||
make
|
||||
make run
|
||||
```
|
||||
Generated
+27
@@ -0,0 +1,27 @@
|
||||
{
|
||||
"nodes": {
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1780749050,
|
||||
"narHash": "sha256-3av0pIjlOWQ6rDbNOmpUSvbNnJkGORQKKjb4LtCZsIY=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "a799d3e3886da994fa307f817a6bc705ae538eeb",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"ref": "nixos-unstable",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"nixpkgs": "nixpkgs"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
"version": 7
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
{
|
||||
description = "Uku native Raylib and Flint development environment";
|
||||
|
||||
inputs = {
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||
};
|
||||
|
||||
outputs = { self, nixpkgs }:
|
||||
let
|
||||
systems = [
|
||||
"x86_64-linux"
|
||||
"aarch64-linux"
|
||||
];
|
||||
|
||||
forAllSystems = nixpkgs.lib.genAttrs systems;
|
||||
|
||||
mkPkgs = system: import nixpkgs {
|
||||
inherit system;
|
||||
config.allowUnsupportedSystem = true;
|
||||
};
|
||||
|
||||
mkShell = system:
|
||||
let
|
||||
pkgs = mkPkgs system;
|
||||
in
|
||||
pkgs.mkShell {
|
||||
packages = with pkgs; [
|
||||
SDL2
|
||||
SDL2.dev
|
||||
gcc
|
||||
gnumake
|
||||
libdrm
|
||||
libdrm.dev
|
||||
libgbm
|
||||
libglvnd
|
||||
libglvnd.dev
|
||||
mesa
|
||||
pkg-config
|
||||
zlib
|
||||
];
|
||||
|
||||
shellHook = ''
|
||||
export RAY_PKGS="sdl2 libdrm gbm egl glesv2"
|
||||
export RAY_SDL_CFLAGS="$(pkg-config --cflags sdl2)"
|
||||
export RAY_SDL_LDLIBS="$(pkg-config --libs sdl2)"
|
||||
export RAY_GL_CFLAGS="$(pkg-config --cflags libdrm gbm egl glesv2)"
|
||||
export RAY_GL_LDLIBS="$(pkg-config --libs libdrm gbm egl glesv2)"
|
||||
export RAY_CFLAGS="$RAY_SDL_CFLAGS $RAY_GL_CFLAGS"
|
||||
export RAY_LDLIBS="$RAY_SDL_LDLIBS $RAY_GL_LDLIBS"
|
||||
export RAY_SDL_INCLUDE_DIR="$(pkg-config --variable=includedir sdl2 | sed 's,/SDL2$,,')"
|
||||
export RAY_RAYLIB_CONFIG="-DSUPPORT_SCREEN_CAPTURE=0 -DSUPPORT_COMPRESSION_API=0 -DSUPPORT_AUTOMATION_EVENTS=0 -DSUPPORT_CLIPBOARD_IMAGE=0 -DSUPPORT_FILEFORMAT_BMP=0 -DSUPPORT_FILEFORMAT_GIF=0 -DSUPPORT_FILEFORMAT_QOI=0 -DSUPPORT_FILEFORMAT_DDS=0 -DSUPPORT_FILEFORMAT_TTF=0"
|
||||
'';
|
||||
};
|
||||
in {
|
||||
devShells = forAllSystems (system: {
|
||||
default = mkShell system;
|
||||
});
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
[app_title]
|
||||
Ukuvota
|
||||
---
|
||||
[home_title]
|
||||
Ukuvota
|
||||
---
|
||||
[home_subtitle]
|
||||
Systemic Consensus
|
||||
---
|
||||
[home_summary]
|
||||
Ukuvota helps groups make collective decisions with score voting. Participants can support or oppose every option, so the result favors choices people can accept and still act on.
|
||||
---
|
||||
[start_process_button]
|
||||
Start Process
|
||||
---
|
||||
[create_title]
|
||||
Decision Setup
|
||||
---
|
||||
[topic_question_label]
|
||||
Topic Question
|
||||
---
|
||||
[topic_question_placeholder]
|
||||
What should this group decide?
|
||||
---
|
||||
[topic_error]
|
||||
Add a topic question to start the process.
|
||||
---
|
||||
[description_label]
|
||||
Description (optional)
|
||||
---
|
||||
[description_placeholder]
|
||||
Add context, constraints, or links.
|
||||
---
|
||||
[negative_weight_label]
|
||||
Negative score weighting
|
||||
---
|
||||
[proposal_time_label]
|
||||
Proposal Time
|
||||
---
|
||||
[voting_time_label]
|
||||
Voting Time
|
||||
---
|
||||
[days_label]
|
||||
Days
|
||||
---
|
||||
[hours_label]
|
||||
Hours
|
||||
---
|
||||
[minutes_label]
|
||||
Minutes
|
||||
---
|
||||
[default_options_label]
|
||||
Default Options
|
||||
---
|
||||
[option_keep_title_label]
|
||||
Option 1 Title
|
||||
---
|
||||
[option_keep_description_label]
|
||||
Option 1 Description
|
||||
---
|
||||
[option_repeat_title_label]
|
||||
Option 2 Title
|
||||
---
|
||||
[option_repeat_description_label]
|
||||
Option 2 Description
|
||||
---
|
||||
[default_keep_title]
|
||||
Status quo
|
||||
---
|
||||
[default_keep_description]
|
||||
Keep things the way they are.
|
||||
---
|
||||
[default_repeat_title]
|
||||
Repeat process
|
||||
---
|
||||
[default_repeat_description]
|
||||
Repeat the process and look for other options.
|
||||
---
|
||||
[create_process_button]
|
||||
Create Process
|
||||
---
|
||||
[setup_ready]
|
||||
Process draft ready.
|
||||
---
|
||||
[back_button]
|
||||
Back
|
||||
---
|
||||
[brand_short]
|
||||
Uku
|
||||
---
|
||||
+834
@@ -0,0 +1,834 @@
|
||||
#include "raylib.h"
|
||||
#include "flint.h"
|
||||
|
||||
#include <math.h>
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#define UKU_MIN(a, b) ((a) < (b) ? (a) : (b))
|
||||
#define UKU_MAX(a, b) ((a) > (b) ? (a) : (b))
|
||||
|
||||
typedef enum UkuScreen {
|
||||
UKU_SCREEN_HOME,
|
||||
UKU_SCREEN_CREATE
|
||||
} UkuScreen;
|
||||
|
||||
typedef enum UkuField {
|
||||
UKU_FIELD_NONE,
|
||||
UKU_FIELD_TOPIC,
|
||||
UKU_FIELD_DESCRIPTION,
|
||||
UKU_FIELD_KEEP_TITLE,
|
||||
UKU_FIELD_KEEP_DESCRIPTION,
|
||||
UKU_FIELD_REPEAT_TITLE,
|
||||
UKU_FIELD_REPEAT_DESCRIPTION
|
||||
} UkuField;
|
||||
|
||||
typedef struct UkuDecision {
|
||||
char topic[180];
|
||||
char description[420];
|
||||
char keep_title[96];
|
||||
char keep_description[180];
|
||||
char repeat_title[96];
|
||||
char repeat_description[180];
|
||||
int proposal_days;
|
||||
int proposal_hours;
|
||||
int proposal_minutes;
|
||||
int voting_days;
|
||||
int voting_hours;
|
||||
int voting_minutes;
|
||||
int negative_weight;
|
||||
int submitted;
|
||||
int topic_error;
|
||||
} UkuDecision;
|
||||
|
||||
typedef struct UkuApp {
|
||||
UkuScreen screen;
|
||||
UkuField active_field;
|
||||
int cursor_clickable;
|
||||
int create_scroll;
|
||||
float logo_spin;
|
||||
Font font;
|
||||
Texture2D font_shapes_texture;
|
||||
int locale_font_ready;
|
||||
UkuDecision decision;
|
||||
} UkuApp;
|
||||
|
||||
typedef struct UkuText {
|
||||
char app_title[64];
|
||||
char home_title[64];
|
||||
char home_subtitle[96];
|
||||
char home_summary[512];
|
||||
char start_process_button[64];
|
||||
char create_title[96];
|
||||
char topic_question_label[96];
|
||||
char topic_question_placeholder[128];
|
||||
char topic_error[128];
|
||||
char description_label[96];
|
||||
char description_placeholder[128];
|
||||
char negative_weight_label[96];
|
||||
char proposal_time_label[96];
|
||||
char voting_time_label[96];
|
||||
char days_label[32];
|
||||
char hours_label[32];
|
||||
char minutes_label[32];
|
||||
char default_options_label[96];
|
||||
char option_keep_title_label[96];
|
||||
char option_keep_description_label[96];
|
||||
char option_repeat_title_label[96];
|
||||
char option_repeat_description_label[96];
|
||||
char default_keep_title[96];
|
||||
char default_keep_description[180];
|
||||
char default_repeat_title[96];
|
||||
char default_repeat_description[180];
|
||||
char create_process_button[96];
|
||||
char setup_ready[96];
|
||||
char back_button[64];
|
||||
char brand_short[64];
|
||||
} UkuText;
|
||||
|
||||
typedef struct ChoppedGlyph {
|
||||
int32_t value;
|
||||
int32_t x;
|
||||
int32_t y;
|
||||
int32_t w;
|
||||
int32_t h;
|
||||
int32_t offsetX;
|
||||
int32_t offsetY;
|
||||
int32_t advanceX;
|
||||
} ChoppedGlyph;
|
||||
|
||||
static const Color C_BG = {250, 248, 242, 255};
|
||||
static const Color C_TEXT = {31, 39, 51, 255};
|
||||
static const Color C_MUTED = {91, 101, 115, 255};
|
||||
static const Color C_LINE = {209, 214, 219, 255};
|
||||
static const Color C_GREEN = {45, 121, 93, 255};
|
||||
static const Color C_BLUE = {42, 92, 156, 255};
|
||||
static const Color C_GOLD = {214, 164, 73, 255};
|
||||
static const Color C_RED = {178, 73, 68, 255};
|
||||
|
||||
#define LOCALE_FONT_PNG "assets/fonts/locales.png"
|
||||
#define LOCALE_FONT_DAT "assets/fonts/locales.dat"
|
||||
#define LOCALE_TEXT_PATH "locales/en.txt"
|
||||
#define LOCALE_FONT_BASE_SIZE 16
|
||||
#define UKU_PACKAGE_ID "xyz.waozi.uku"
|
||||
|
||||
static void
|
||||
copy_text(char *dst, size_t dst_size, const char *src, size_t len)
|
||||
{
|
||||
size_t n;
|
||||
|
||||
if(dst == NULL || dst_size == 0)
|
||||
return;
|
||||
|
||||
while(len > 0 && (src[len - 1] == '\n' || src[len - 1] == '\r'))
|
||||
len--;
|
||||
n = UKU_MIN(len, dst_size - 1);
|
||||
memcpy(dst, src, n);
|
||||
dst[n] = '\0';
|
||||
}
|
||||
|
||||
static void
|
||||
set_default_text(UkuText *text)
|
||||
{
|
||||
memset(text, 0, sizeof(*text));
|
||||
}
|
||||
|
||||
static void
|
||||
assign_text(UkuText *text, const char *key, const char *value, size_t len)
|
||||
{
|
||||
if(strcmp(key, "app_title") == 0)
|
||||
copy_text(text->app_title, sizeof(text->app_title), value, len);
|
||||
else if(strcmp(key, "home_title") == 0)
|
||||
copy_text(text->home_title, sizeof(text->home_title), value, len);
|
||||
else if(strcmp(key, "home_subtitle") == 0)
|
||||
copy_text(text->home_subtitle, sizeof(text->home_subtitle), value, len);
|
||||
else if(strcmp(key, "home_summary") == 0)
|
||||
copy_text(text->home_summary, sizeof(text->home_summary), value, len);
|
||||
else if(strcmp(key, "start_process_button") == 0)
|
||||
copy_text(text->start_process_button, sizeof(text->start_process_button), value, len);
|
||||
else if(strcmp(key, "create_title") == 0)
|
||||
copy_text(text->create_title, sizeof(text->create_title), value, len);
|
||||
else if(strcmp(key, "topic_question_label") == 0)
|
||||
copy_text(text->topic_question_label, sizeof(text->topic_question_label), value, len);
|
||||
else if(strcmp(key, "topic_question_placeholder") == 0)
|
||||
copy_text(text->topic_question_placeholder, sizeof(text->topic_question_placeholder), value, len);
|
||||
else if(strcmp(key, "topic_error") == 0)
|
||||
copy_text(text->topic_error, sizeof(text->topic_error), value, len);
|
||||
else if(strcmp(key, "description_label") == 0)
|
||||
copy_text(text->description_label, sizeof(text->description_label), value, len);
|
||||
else if(strcmp(key, "description_placeholder") == 0)
|
||||
copy_text(text->description_placeholder, sizeof(text->description_placeholder), value, len);
|
||||
else if(strcmp(key, "negative_weight_label") == 0)
|
||||
copy_text(text->negative_weight_label, sizeof(text->negative_weight_label), value, len);
|
||||
else if(strcmp(key, "proposal_time_label") == 0)
|
||||
copy_text(text->proposal_time_label, sizeof(text->proposal_time_label), value, len);
|
||||
else if(strcmp(key, "voting_time_label") == 0)
|
||||
copy_text(text->voting_time_label, sizeof(text->voting_time_label), value, len);
|
||||
else if(strcmp(key, "days_label") == 0)
|
||||
copy_text(text->days_label, sizeof(text->days_label), value, len);
|
||||
else if(strcmp(key, "hours_label") == 0)
|
||||
copy_text(text->hours_label, sizeof(text->hours_label), value, len);
|
||||
else if(strcmp(key, "minutes_label") == 0)
|
||||
copy_text(text->minutes_label, sizeof(text->minutes_label), value, len);
|
||||
else if(strcmp(key, "default_options_label") == 0)
|
||||
copy_text(text->default_options_label, sizeof(text->default_options_label), value, len);
|
||||
else if(strcmp(key, "option_keep_title_label") == 0)
|
||||
copy_text(text->option_keep_title_label, sizeof(text->option_keep_title_label), value, len);
|
||||
else if(strcmp(key, "option_keep_description_label") == 0)
|
||||
copy_text(text->option_keep_description_label, sizeof(text->option_keep_description_label), value, len);
|
||||
else if(strcmp(key, "option_repeat_title_label") == 0)
|
||||
copy_text(text->option_repeat_title_label, sizeof(text->option_repeat_title_label), value, len);
|
||||
else if(strcmp(key, "option_repeat_description_label") == 0)
|
||||
copy_text(text->option_repeat_description_label, sizeof(text->option_repeat_description_label), value, len);
|
||||
else if(strcmp(key, "default_keep_title") == 0)
|
||||
copy_text(text->default_keep_title, sizeof(text->default_keep_title), value, len);
|
||||
else if(strcmp(key, "default_keep_description") == 0)
|
||||
copy_text(text->default_keep_description, sizeof(text->default_keep_description), value, len);
|
||||
else if(strcmp(key, "default_repeat_title") == 0)
|
||||
copy_text(text->default_repeat_title, sizeof(text->default_repeat_title), value, len);
|
||||
else if(strcmp(key, "default_repeat_description") == 0)
|
||||
copy_text(text->default_repeat_description, sizeof(text->default_repeat_description), value, len);
|
||||
else if(strcmp(key, "create_process_button") == 0)
|
||||
copy_text(text->create_process_button, sizeof(text->create_process_button), value, len);
|
||||
else if(strcmp(key, "setup_ready") == 0)
|
||||
copy_text(text->setup_ready, sizeof(text->setup_ready), value, len);
|
||||
else if(strcmp(key, "back_button") == 0)
|
||||
copy_text(text->back_button, sizeof(text->back_button), value, len);
|
||||
else if(strcmp(key, "brand_short") == 0)
|
||||
copy_text(text->brand_short, sizeof(text->brand_short), value, len);
|
||||
}
|
||||
|
||||
static void
|
||||
load_text_file(UkuText *text, const char *path)
|
||||
{
|
||||
char *data = LoadFileText(path);
|
||||
char key[96] = {0};
|
||||
char *line;
|
||||
char *value_start = NULL;
|
||||
|
||||
set_default_text(text);
|
||||
if(data == NULL)
|
||||
return;
|
||||
|
||||
line = data;
|
||||
while(line != NULL && *line != '\0') {
|
||||
char *next = strchr(line, '\n');
|
||||
size_t line_len = next == NULL ? strlen(line) : (size_t)(next - line);
|
||||
|
||||
if(line_len > 0 && line[line_len - 1] == '\r')
|
||||
line_len--;
|
||||
|
||||
if(line_len >= 3 && strncmp(line, "---", 3) == 0) {
|
||||
if(key[0] != '\0' && value_start != NULL)
|
||||
assign_text(text, key, value_start, (size_t)(line - value_start));
|
||||
key[0] = '\0';
|
||||
value_start = NULL;
|
||||
} else if(line_len >= 3 && line[0] == '[' && line[line_len - 1] == ']') {
|
||||
size_t key_len = UKU_MIN(line_len - 2, sizeof(key) - 1);
|
||||
memcpy(key, line + 1, key_len);
|
||||
key[key_len] = '\0';
|
||||
value_start = next == NULL ? NULL : next + 1;
|
||||
}
|
||||
|
||||
if(next == NULL)
|
||||
break;
|
||||
line = next + 1;
|
||||
}
|
||||
|
||||
if(key[0] != '\0' && value_start != NULL)
|
||||
assign_text(text, key, value_start, strlen(value_start));
|
||||
|
||||
UnloadFileText(data);
|
||||
}
|
||||
|
||||
static Font
|
||||
load_chopped_font(const char *png_path, const char *dat_path)
|
||||
{
|
||||
Font font = {0};
|
||||
FILE *file = NULL;
|
||||
ChoppedGlyph *glyphs = NULL;
|
||||
GlyphInfo *glyph_infos = NULL;
|
||||
Rectangle *recs = NULL;
|
||||
int32_t glyph_count = 0;
|
||||
Image image = {0};
|
||||
Texture2D texture = {0};
|
||||
|
||||
file = fopen(dat_path, "rb");
|
||||
if(file == NULL)
|
||||
return font;
|
||||
|
||||
if(fread(&glyph_count, sizeof(glyph_count), 1, file) != 1 || glyph_count <= 0) {
|
||||
fclose(file);
|
||||
return font;
|
||||
}
|
||||
|
||||
glyphs = calloc((size_t)glyph_count, sizeof(*glyphs));
|
||||
glyph_infos = calloc((size_t)glyph_count, sizeof(*glyph_infos));
|
||||
recs = calloc((size_t)glyph_count, sizeof(*recs));
|
||||
if(glyphs == NULL || glyph_infos == NULL || recs == NULL)
|
||||
goto cleanup;
|
||||
|
||||
if(fread(glyphs, sizeof(*glyphs), (size_t)glyph_count, file) != (size_t)glyph_count)
|
||||
goto cleanup;
|
||||
fclose(file);
|
||||
file = NULL;
|
||||
|
||||
image = LoadImage(png_path);
|
||||
if(image.data == NULL)
|
||||
goto cleanup;
|
||||
|
||||
texture = LoadTextureFromImage(image);
|
||||
UnloadImage(image);
|
||||
image = (Image){0};
|
||||
if(texture.id == 0)
|
||||
goto cleanup;
|
||||
SetTextureFilter(texture, TEXTURE_FILTER_POINT);
|
||||
|
||||
for(int i = 0; i < glyph_count; i++) {
|
||||
glyph_infos[i].value = glyphs[i].value;
|
||||
glyph_infos[i].offsetX = glyphs[i].offsetX;
|
||||
glyph_infos[i].offsetY = glyphs[i].offsetY;
|
||||
glyph_infos[i].advanceX = glyphs[i].advanceX;
|
||||
glyph_infos[i].image = (Image){0};
|
||||
|
||||
recs[i].x = (float)glyphs[i].x;
|
||||
recs[i].y = (float)glyphs[i].y;
|
||||
recs[i].width = (float)glyphs[i].w;
|
||||
recs[i].height = (float)glyphs[i].h;
|
||||
}
|
||||
|
||||
font.texture = texture;
|
||||
font.glyphs = glyph_infos;
|
||||
font.recs = recs;
|
||||
font.glyphCount = glyph_count;
|
||||
font.baseSize = LOCALE_FONT_BASE_SIZE;
|
||||
font.glyphPadding = 0;
|
||||
|
||||
free(glyphs);
|
||||
return font;
|
||||
|
||||
cleanup:
|
||||
if(file != NULL)
|
||||
fclose(file);
|
||||
if(image.data != NULL)
|
||||
UnloadImage(image);
|
||||
if(texture.id != 0)
|
||||
UnloadTexture(texture);
|
||||
free(glyphs);
|
||||
free(glyph_infos);
|
||||
free(recs);
|
||||
return (Font){0};
|
||||
}
|
||||
|
||||
static void
|
||||
app_load_font(UkuApp *app)
|
||||
{
|
||||
Image white;
|
||||
|
||||
app->font = load_chopped_font(LOCALE_FONT_PNG, LOCALE_FONT_DAT);
|
||||
if(app->font.texture.id == 0) {
|
||||
app->font = GetFontDefault();
|
||||
app->locale_font_ready = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
white = GenImageColor(1, 1, WHITE);
|
||||
app->font_shapes_texture = LoadTextureFromImage(white);
|
||||
UnloadImage(white);
|
||||
if(app->font_shapes_texture.id != 0)
|
||||
SetShapesTexture(app->font_shapes_texture, (Rectangle){0, 0, 1, 1});
|
||||
app->locale_font_ready = 1;
|
||||
}
|
||||
|
||||
static void
|
||||
app_unload_font(UkuApp *app)
|
||||
{
|
||||
if(app->locale_font_ready) {
|
||||
UnloadTexture(app->font.texture);
|
||||
free(app->font.glyphs);
|
||||
free(app->font.recs);
|
||||
}
|
||||
if(app->font_shapes_texture.id != 0)
|
||||
UnloadTexture(app->font_shapes_texture);
|
||||
}
|
||||
|
||||
static int
|
||||
measure_text_font(Font font, const char *text, int font_size)
|
||||
{
|
||||
return (int)(MeasureTextEx(font, text, (float)font_size, 0).x + 0.5f);
|
||||
}
|
||||
|
||||
static void
|
||||
draw_text_font(Font font, const char *text, int x, int y, int font_size, Color color)
|
||||
{
|
||||
DrawTextEx(font, text, (Vector2){(float)x, (float)y}, (float)font_size, 0, color);
|
||||
}
|
||||
|
||||
static int
|
||||
draw_wrapped_text(Font font, const char *text, int x, int y, int w, int font_size, int line_h, Color color)
|
||||
{
|
||||
const char *p = text;
|
||||
char line[512];
|
||||
int line_len = 0;
|
||||
int line_w = 0;
|
||||
int space_w = measure_text_font(font, " ", font_size);
|
||||
|
||||
line[0] = '\0';
|
||||
while(*p != '\0') {
|
||||
char word[160];
|
||||
int word_len = 0;
|
||||
int forced_break = 0;
|
||||
|
||||
while(*p == ' ')
|
||||
p++;
|
||||
if(*p == '\n') {
|
||||
forced_break = 1;
|
||||
p++;
|
||||
}
|
||||
|
||||
while(*p != '\0' && *p != ' ' && *p != '\n' && word_len < (int)sizeof(word) - 1)
|
||||
word[word_len++] = *p++;
|
||||
word[word_len] = '\0';
|
||||
|
||||
if(forced_break || word_len == 0) {
|
||||
if(line_len > 0) {
|
||||
draw_text_font(font, line, x, y, font_size, color);
|
||||
y += line_h;
|
||||
line_len = 0;
|
||||
line_w = 0;
|
||||
line[0] = '\0';
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
int word_w = measure_text_font(font, word, font_size);
|
||||
int add_w = line_len == 0 ? word_w : space_w + word_w;
|
||||
if(line_len > 0 && line_w + add_w > w) {
|
||||
draw_text_font(font, line, x, y, font_size, color);
|
||||
y += line_h;
|
||||
line_len = 0;
|
||||
line_w = 0;
|
||||
line[0] = '\0';
|
||||
}
|
||||
|
||||
if(line_len == 0) {
|
||||
copy_text(line, sizeof(line), word, (size_t)word_len);
|
||||
line_len = (int)strlen(line);
|
||||
line_w = word_w;
|
||||
} else if(line_len + 1 + word_len < (int)sizeof(line)) {
|
||||
line[line_len++] = ' ';
|
||||
memcpy(line + line_len, word, (size_t)word_len + 1);
|
||||
line_len += word_len;
|
||||
line_w += add_w;
|
||||
}
|
||||
}
|
||||
|
||||
if(line_len > 0) {
|
||||
draw_text_font(font, line, x, y, font_size, color);
|
||||
y += line_h;
|
||||
}
|
||||
|
||||
return y;
|
||||
}
|
||||
|
||||
static void
|
||||
draw_centered_text(Font font, const char *text, int center_x, int y, int font_size, Color color)
|
||||
{
|
||||
draw_text_font(font, text, center_x - measure_text_font(font, text, font_size) / 2, y, font_size, color);
|
||||
}
|
||||
|
||||
static int
|
||||
clampi(int value, int min_value, int max_value)
|
||||
{
|
||||
if(value < min_value)
|
||||
return min_value;
|
||||
if(value > max_value)
|
||||
return max_value;
|
||||
return value;
|
||||
}
|
||||
|
||||
static int
|
||||
has_non_space(const char *text)
|
||||
{
|
||||
for(const char *p = text; *p != '\0'; p++) {
|
||||
if(*p != ' ' && *p != '\t' && *p != '\n' && *p != '\r')
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
append_char(char *buffer, size_t cap, int codepoint)
|
||||
{
|
||||
size_t len = strlen(buffer);
|
||||
|
||||
if(codepoint < 32 || codepoint > 126 || len + 1 >= cap)
|
||||
return;
|
||||
|
||||
buffer[len] = (char)codepoint;
|
||||
buffer[len + 1] = '\0';
|
||||
}
|
||||
|
||||
static void
|
||||
delete_char(char *buffer)
|
||||
{
|
||||
size_t len = strlen(buffer);
|
||||
|
||||
if(len > 0)
|
||||
buffer[len - 1] = '\0';
|
||||
}
|
||||
|
||||
static const char *
|
||||
fit_tail(Font font, const char *text, int font_size, int w)
|
||||
{
|
||||
const char *p = text;
|
||||
|
||||
while(*p != '\0' && measure_text_font(font, p, font_size) > w)
|
||||
p++;
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
static void
|
||||
draw_logo(int cx, int cy, int size, float spin)
|
||||
{
|
||||
float radius = (float)size * 0.42f;
|
||||
Vector2 center = {(float)cx, (float)cy};
|
||||
Color colors[5] = {C_GREEN, C_BLUE, C_GOLD, C_RED, (Color){91, 68, 148, 255}};
|
||||
|
||||
DrawCircle(cx, cy, radius + flint_px(8), (Color){236, 232, 221, 255});
|
||||
for(int i = 0; i < 5; i++) {
|
||||
float a = spin + (float)i * 72.0f * DEG2RAD - PI / 2.0f;
|
||||
Vector2 p = {
|
||||
center.x + cosf(a) * radius,
|
||||
center.y + sinf(a) * radius
|
||||
};
|
||||
DrawLineEx(center, p, (float)flint_px(5), colors[i]);
|
||||
DrawCircleV(p, (float)flint_px(12), colors[i]);
|
||||
}
|
||||
DrawCircle(cx, cy, flint_px(15), C_TEXT);
|
||||
DrawCircle(cx, cy, flint_px(7), C_BG);
|
||||
}
|
||||
|
||||
static void
|
||||
draw_button(UkuApp *app, Font font, int x, int y, int w, int h, const char *label, int primary, int *clicked)
|
||||
{
|
||||
Vector2 mouse = GetMousePosition();
|
||||
Rectangle bounds = {(float)x, (float)y, (float)w, (float)h};
|
||||
int hover = CheckCollisionPointRec(mouse, bounds);
|
||||
Color fill = primary ? C_BLUE : (Color){255, 255, 255, 255};
|
||||
Color text = primary ? WHITE : C_TEXT;
|
||||
int font_size = flint_clamp_px(16, 16, 20);
|
||||
|
||||
if(hover) {
|
||||
fill = primary ? flint_lighten(C_BLUE, 18) : (Color){242, 245, 247, 255};
|
||||
app->cursor_clickable = 1;
|
||||
}
|
||||
|
||||
DrawRectangleRounded(bounds, 0.12f, 12, fill);
|
||||
DrawRectangleRoundedLinesEx(bounds, 0.12f, 12, flint_px(1), primary ? flint_darken(C_BLUE, 20) : C_LINE);
|
||||
draw_centered_text(font, label, x + w / 2, y + (h - font_size) / 2, font_size, text);
|
||||
|
||||
*clicked = hover && IsMouseButtonReleased(MOUSE_LEFT_BUTTON);
|
||||
}
|
||||
|
||||
static int
|
||||
draw_text_field(UkuApp *app, Font font, const char *label, const char *placeholder,
|
||||
char *buffer, size_t cap, UkuField field, int x, int y, int w, int h)
|
||||
{
|
||||
int label_font = flint_clamp_px(13, 13, 16);
|
||||
int input_font = flint_clamp_px(16, 16, 20);
|
||||
int pad = flint_px(12);
|
||||
int label_y = y;
|
||||
int box_y = y + label_font + flint_px(8);
|
||||
Rectangle box = {(float)x, (float)box_y, (float)w, (float)h};
|
||||
Vector2 mouse = GetMousePosition();
|
||||
int active;
|
||||
|
||||
draw_text_font(font, label, x, label_y, label_font, C_MUTED);
|
||||
|
||||
if(IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) {
|
||||
if(CheckCollisionPointRec(mouse, box))
|
||||
app->active_field = field;
|
||||
else if(app->active_field == field)
|
||||
app->active_field = UKU_FIELD_NONE;
|
||||
}
|
||||
|
||||
active = app->active_field == field;
|
||||
if(CheckCollisionPointRec(mouse, box))
|
||||
app->cursor_clickable = 1;
|
||||
|
||||
if(active) {
|
||||
int c = GetCharPressed();
|
||||
while(c > 0) {
|
||||
append_char(buffer, cap, c);
|
||||
c = GetCharPressed();
|
||||
}
|
||||
if(IsKeyPressed(KEY_BACKSPACE) || IsKeyPressedRepeat(KEY_BACKSPACE))
|
||||
delete_char(buffer);
|
||||
}
|
||||
|
||||
DrawRectangleRounded(box, 0.08f, 10, WHITE);
|
||||
DrawRectangleRoundedLinesEx(box, 0.08f, 10, flint_px(active ? 2 : 1),
|
||||
active ? C_BLUE : C_LINE);
|
||||
|
||||
if(buffer[0] == '\0') {
|
||||
draw_text_font(font, placeholder, x + pad, box_y + pad, input_font, (Color){142, 149, 160, 255});
|
||||
} else if(h > flint_px(58)) {
|
||||
BeginScissorMode(x + pad, box_y + pad, w - pad * 2, h - pad * 2);
|
||||
draw_wrapped_text(font, buffer, x + pad, box_y + pad, w - pad * 2,
|
||||
input_font, input_font + flint_px(7), C_TEXT);
|
||||
EndScissorMode();
|
||||
} else {
|
||||
const char *visible = fit_tail(font, buffer, input_font, w - pad * 2 - flint_px(8));
|
||||
draw_text_font(font, visible, x + pad, box_y + (h - input_font) / 2, input_font, C_TEXT);
|
||||
}
|
||||
|
||||
if(active && ((int)(GetTime() * 2.0) % 2) == 0) {
|
||||
int cursor_x;
|
||||
if(h > flint_px(58))
|
||||
cursor_x = x + pad + UKU_MIN(measure_text_font(font, buffer, input_font), w - pad * 2 - flint_px(4));
|
||||
else
|
||||
cursor_x = x + pad + measure_text_font(font, fit_tail(font, buffer, input_font, w - pad * 2 - flint_px(8)), input_font);
|
||||
DrawLine(cursor_x, box_y + pad, cursor_x, box_y + h - pad, C_BLUE);
|
||||
}
|
||||
|
||||
return box_y + h + flint_px(16);
|
||||
}
|
||||
|
||||
static int
|
||||
draw_stepper(UkuApp *app, Font font, const char *label, int *value, int min_value, int max_value,
|
||||
int x, int y, int w)
|
||||
{
|
||||
int label_font = flint_clamp_px(13, 13, 16);
|
||||
int value_font = flint_clamp_px(18, 18, 22);
|
||||
int btn = flint_px(34);
|
||||
int h = flint_px(38);
|
||||
int value_w = w - btn * 2 - flint_px(8);
|
||||
int minus_clicked = 0;
|
||||
int plus_clicked = 0;
|
||||
char value_text[16];
|
||||
|
||||
draw_text_font(font, label, x, y, label_font, C_MUTED);
|
||||
y += label_font + flint_px(7);
|
||||
|
||||
draw_button(app, font, x, y, btn, h, "-", 0, &minus_clicked);
|
||||
DrawRectangleRounded((Rectangle){x + btn + flint_px(4), y, value_w, h}, 0.08f, 10, WHITE);
|
||||
DrawRectangleRoundedLinesEx((Rectangle){x + btn + flint_px(4), y, value_w, h}, 0.08f, 10, flint_px(1), C_LINE);
|
||||
snprintf(value_text, sizeof(value_text), "%d", *value);
|
||||
draw_centered_text(font, value_text, x + btn + flint_px(4) + value_w / 2,
|
||||
y + (h - value_font) / 2, value_font, C_TEXT);
|
||||
draw_button(app, font, x + btn + flint_px(8) + value_w, y, btn, h, "+", 0, &plus_clicked);
|
||||
|
||||
if(minus_clicked)
|
||||
*value = clampi(*value - 1, min_value, max_value);
|
||||
if(plus_clicked)
|
||||
*value = clampi(*value + 1, min_value, max_value);
|
||||
|
||||
return y + h + flint_px(14);
|
||||
}
|
||||
|
||||
static int
|
||||
draw_duration_group(UkuApp *app, Font font, const char *title, const UkuText *text,
|
||||
int *days, int *hours, int *minutes, int x, int y, int w)
|
||||
{
|
||||
int title_font = flint_clamp_px(16, 16, 20);
|
||||
int gap = flint_px(10);
|
||||
int col_w = (w - gap * 2) / 3;
|
||||
int y2;
|
||||
|
||||
draw_text_font(font, title, x, y, title_font, C_TEXT);
|
||||
y += title_font + flint_px(12);
|
||||
|
||||
y2 = draw_stepper(app, font, text->days_label, days, 0, 30, x, y, col_w);
|
||||
draw_stepper(app, font, text->hours_label, hours, 0, 23, x + col_w + gap, y, col_w);
|
||||
draw_stepper(app, font, text->minutes_label, minutes, 0, 59, x + (col_w + gap) * 2, y, col_w);
|
||||
return y2 + flint_px(6);
|
||||
}
|
||||
|
||||
static void
|
||||
init_decision(UkuApp *app, const UkuText *text)
|
||||
{
|
||||
UkuDecision *d = &app->decision;
|
||||
|
||||
copy_text(d->keep_title, sizeof(d->keep_title), text->default_keep_title, strlen(text->default_keep_title));
|
||||
copy_text(d->keep_description, sizeof(d->keep_description),
|
||||
text->default_keep_description, strlen(text->default_keep_description));
|
||||
copy_text(d->repeat_title, sizeof(d->repeat_title), text->default_repeat_title, strlen(text->default_repeat_title));
|
||||
copy_text(d->repeat_description, sizeof(d->repeat_description),
|
||||
text->default_repeat_description, strlen(text->default_repeat_description));
|
||||
d->proposal_days = 2;
|
||||
d->proposal_hours = 0;
|
||||
d->proposal_minutes = 1;
|
||||
d->voting_days = 1;
|
||||
d->voting_hours = 0;
|
||||
d->voting_minutes = 1;
|
||||
d->negative_weight = 3;
|
||||
}
|
||||
|
||||
static void
|
||||
draw_home(UkuApp *app, const UkuText *text, int view_w, int view_h)
|
||||
{
|
||||
int side = flint_page_side_padding();
|
||||
int content_x;
|
||||
int content_w;
|
||||
int top = flint_px(28);
|
||||
int logo_size = flint_clamp_px(86, 72, 116);
|
||||
int title_font = flint_clamp_px(34, 30, 44);
|
||||
int body_font = flint_clamp_px(16, 16, 20);
|
||||
int small_font = flint_clamp_px(13, 13, 16);
|
||||
int line_h = body_font + flint_px(8);
|
||||
int y;
|
||||
int button_w;
|
||||
int button_x;
|
||||
int clicked = 0;
|
||||
Font font = app->font;
|
||||
|
||||
flint_centered_column(700, side, &content_x, &content_w);
|
||||
|
||||
draw_logo(view_w / 2, top + logo_size / 2, logo_size, app->logo_spin);
|
||||
y = top + logo_size + flint_px(18);
|
||||
|
||||
draw_centered_text(font, text->home_title, view_w / 2, y, title_font, C_TEXT);
|
||||
y += title_font + flint_px(8);
|
||||
|
||||
draw_centered_text(font, text->home_subtitle, view_w / 2, y, small_font, C_GREEN);
|
||||
y += small_font + flint_px(24);
|
||||
|
||||
y = draw_wrapped_text(font, text->home_summary, content_x, y, content_w, body_font, line_h, C_TEXT);
|
||||
y += flint_px(30);
|
||||
|
||||
button_w = UKU_MIN(content_w, flint_px(280));
|
||||
button_x = content_x + (content_w - button_w) / 2;
|
||||
draw_button(app, font, button_x, y, button_w, flint_px(48), text->start_process_button, 1, &clicked);
|
||||
if(clicked)
|
||||
app->screen = UKU_SCREEN_CREATE;
|
||||
|
||||
(void)view_h;
|
||||
}
|
||||
|
||||
static void
|
||||
draw_create_placeholder(UkuApp *app, const UkuText *text, int view_w, int view_h)
|
||||
{
|
||||
int side = flint_page_side_padding();
|
||||
int content_x;
|
||||
int content_w;
|
||||
int title_font = flint_clamp_px(28, 26, 38);
|
||||
int small_font = flint_clamp_px(13, 13, 16);
|
||||
int y = flint_px(30) - app->create_scroll;
|
||||
int start_y = y;
|
||||
int clicked = 0;
|
||||
int back_clicked = 0;
|
||||
Font font = app->font;
|
||||
UkuDecision *d = &app->decision;
|
||||
int max_scroll;
|
||||
|
||||
app->create_scroll = clampi(app->create_scroll - (int)(GetMouseWheelMove() * flint_px(44)), 0, 2000);
|
||||
flint_centered_column(680, side, &content_x, &content_w);
|
||||
|
||||
draw_text_font(font, text->create_title, content_x, y, title_font, C_TEXT);
|
||||
draw_button(app, font, content_x + content_w - flint_px(120), y, flint_px(120), flint_px(40),
|
||||
text->back_button, 0, &back_clicked);
|
||||
if(back_clicked) {
|
||||
app->screen = UKU_SCREEN_HOME;
|
||||
app->active_field = UKU_FIELD_NONE;
|
||||
}
|
||||
y += title_font + flint_px(24);
|
||||
|
||||
BeginScissorMode(0, flint_px(78), view_w, view_h - flint_px(78));
|
||||
y = draw_text_field(app, font, text->topic_question_label, text->topic_question_placeholder,
|
||||
d->topic, sizeof(d->topic), UKU_FIELD_TOPIC,
|
||||
content_x, y, content_w, flint_px(46));
|
||||
if(d->topic_error) {
|
||||
draw_text_font(font, text->topic_error, content_x, y - flint_px(8), small_font, C_RED);
|
||||
y += small_font + flint_px(8);
|
||||
}
|
||||
y = draw_text_field(app, font, text->description_label, text->description_placeholder,
|
||||
d->description, sizeof(d->description), UKU_FIELD_DESCRIPTION,
|
||||
content_x, y, content_w, flint_px(82));
|
||||
y = draw_stepper(app, font, text->negative_weight_label, &d->negative_weight, 1, 9,
|
||||
content_x, y, UKU_MIN(content_w, flint_px(250)));
|
||||
y += flint_px(6);
|
||||
y = draw_duration_group(app, font, text->proposal_time_label, text,
|
||||
&d->proposal_days, &d->proposal_hours, &d->proposal_minutes,
|
||||
content_x, y, content_w);
|
||||
y = draw_duration_group(app, font, text->voting_time_label, text,
|
||||
&d->voting_days, &d->voting_hours, &d->voting_minutes,
|
||||
content_x, y, content_w);
|
||||
|
||||
draw_text_font(font, text->default_options_label, content_x, y, title_font - flint_px(6), C_TEXT);
|
||||
y += title_font + flint_px(10);
|
||||
y = draw_text_field(app, font, text->option_keep_title_label, "",
|
||||
d->keep_title, sizeof(d->keep_title), UKU_FIELD_KEEP_TITLE,
|
||||
content_x, y, content_w, flint_px(44));
|
||||
y = draw_text_field(app, font, text->option_keep_description_label, "",
|
||||
d->keep_description, sizeof(d->keep_description), UKU_FIELD_KEEP_DESCRIPTION,
|
||||
content_x, y, content_w, flint_px(64));
|
||||
y = draw_text_field(app, font, text->option_repeat_title_label, "",
|
||||
d->repeat_title, sizeof(d->repeat_title), UKU_FIELD_REPEAT_TITLE,
|
||||
content_x, y, content_w, flint_px(44));
|
||||
y = draw_text_field(app, font, text->option_repeat_description_label, "",
|
||||
d->repeat_description, sizeof(d->repeat_description), UKU_FIELD_REPEAT_DESCRIPTION,
|
||||
content_x, y, content_w, flint_px(64));
|
||||
draw_button(app, font, content_x, y, content_w, flint_px(48), text->create_process_button, 1, &clicked);
|
||||
if(clicked) {
|
||||
d->topic_error = !has_non_space(d->topic);
|
||||
d->submitted = !d->topic_error;
|
||||
}
|
||||
y += flint_px(62);
|
||||
if(d->submitted)
|
||||
draw_centered_text(font, text->setup_ready, content_x + content_w / 2, y, small_font, C_GREEN);
|
||||
EndScissorMode();
|
||||
|
||||
max_scroll = UKU_MAX(0, (y + app->create_scroll + flint_px(24)) - view_h);
|
||||
app->create_scroll = clampi(app->create_scroll, 0, max_scroll);
|
||||
(void)start_y;
|
||||
}
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
UkuApp app = {0};
|
||||
UkuText text = {0};
|
||||
|
||||
load_text_file(&text, LOCALE_TEXT_PATH);
|
||||
init_decision(&app, &text);
|
||||
|
||||
SetConfigFlags(FLAG_WINDOW_RESIZABLE);
|
||||
InitWindow(520, 760, text.app_title);
|
||||
SetTargetFPS(60);
|
||||
flint_dpi_init();
|
||||
app_load_font(&app);
|
||||
|
||||
while(!WindowShouldClose()) {
|
||||
int view_w = GetScreenWidth();
|
||||
int view_h = GetScreenHeight();
|
||||
|
||||
flint_dpi_update(view_w, view_h);
|
||||
flint_set_dpi_scale(flint_dpi_state.ui_scale_clamped);
|
||||
flint_set_view_size(view_w, view_h);
|
||||
ui_init(view_w, view_h, flint_get_dpi_scale());
|
||||
ui_set_frame((Camera2D){0});
|
||||
ui_set_cursor_clickable(&app.cursor_clickable);
|
||||
ui_set_colors(C_TEXT, C_BG, C_GREEN, C_BLUE, flint_lighten(C_BLUE, 18), C_TEXT);
|
||||
|
||||
app.cursor_clickable = 0;
|
||||
app.logo_spin += GetFrameTime() * 0.35f;
|
||||
|
||||
BeginDrawing();
|
||||
ClearBackground(C_BG);
|
||||
if(app.screen == UKU_SCREEN_HOME)
|
||||
draw_home(&app, &text, view_w, view_h);
|
||||
else
|
||||
draw_create_placeholder(&app, &text, view_w, view_h);
|
||||
EndDrawing();
|
||||
|
||||
SetMouseCursor(app.cursor_clickable ? MOUSE_CURSOR_POINTING_HAND : MOUSE_CURSOR_DEFAULT);
|
||||
}
|
||||
|
||||
app_unload_font(&app);
|
||||
CloseWindow();
|
||||
return 0;
|
||||
}
|
||||
Reference in new issue
Block a user