v0.9.5 beta — full feature build ready for distribution
Core additions since initial commit: - Platform-split MIDI (midi_linux.c / midi_windows.c) - Patch system: save/load/scan, subdirectory navigation, favourites - Config system: last MIDI device and CC mappings persisted to disk - Custom embedded pixel font and sprite sheet (no loose asset files at runtime) - Window icon embedded at runtime (SetWindowIcon) and in Windows .exe (windres) - chdirToExeDir() in platform.c so double-click launch finds patches/ correctly - About screen accessible from Master panel UI polish: - TITLE_BAR_H constant (20 px) — sprite buttons now fit inside title bars - All title bar text, button overlay text, and close/active labels vertically centred - Full-screen dim overlay computed from camera transform (no more partial coverage) - Patch browser: folder navigation, breadcrumb title, 256-slot limit lifted Build: - Makefile auto-discovers sources; embeds sprites/font/icon via xxd rules - Windows cross-compile: make PLATFORM=windows (mingw-w64 + windres) - windows.h isolated in platform.c to avoid Rectangle/CloseWindow conflicts with raylib.h - WIN_RES uses lazy = assignment so OBJ_DIR expands correctly for windres output path Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
91
source/config.c
Normal file
91
source/config.c
Normal file
@@ -0,0 +1,91 @@
|
||||
#define _POSIX_C_SOURCE 200809L
|
||||
#include "config.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#ifdef _WIN32
|
||||
# include <direct.h>
|
||||
# define MAKE_DIR(p) _mkdir(p)
|
||||
#else
|
||||
# include <sys/stat.h>
|
||||
# define MAKE_DIR(p) mkdir(p, 0755)
|
||||
#endif
|
||||
|
||||
void configSanitizeName(const char *in, char *out, int maxLen)
|
||||
{
|
||||
int i = 0;
|
||||
for (; in[i] && i < maxLen - 1; i++) {
|
||||
char c = in[i];
|
||||
if ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') ||
|
||||
(c >= '0' && c <= '9') || c == '_' || c == '-')
|
||||
out[i] = c;
|
||||
else
|
||||
out[i] = '_';
|
||||
}
|
||||
out[i] = '\0';
|
||||
}
|
||||
|
||||
int configSaveLastDevice(const char *deviceName)
|
||||
{
|
||||
MAKE_DIR(CONFIG_DIR);
|
||||
FILE *f = fopen(CONFIG_DIR "/last_device.txt", "w");
|
||||
if (!f) return 0;
|
||||
fprintf(f, "%s\n", deviceName);
|
||||
fclose(f);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int configLoadLastDevice(char *out, int maxLen)
|
||||
{
|
||||
FILE *f = fopen(CONFIG_DIR "/last_device.txt", "r");
|
||||
if (!f) return 0;
|
||||
int ok = (fgets(out, maxLen, f) != NULL);
|
||||
fclose(f);
|
||||
if (!ok) return 0;
|
||||
int len = (int)strlen(out);
|
||||
if (len > 0 && out[len - 1] == '\n') out[len - 1] = '\0';
|
||||
return out[0] != '\0';
|
||||
}
|
||||
|
||||
int configSaveCcMappings(const char *deviceName, ConfigCcEntry *entries, int count)
|
||||
{
|
||||
MAKE_DIR(CONFIG_DIR);
|
||||
char safe[CONFIG_NAME_LEN];
|
||||
configSanitizeName(deviceName, safe, sizeof(safe));
|
||||
char path[CONFIG_NAME_LEN + 32];
|
||||
snprintf(path, sizeof(path), CONFIG_DIR "/cc_%s.cfg", safe);
|
||||
|
||||
FILE *f = fopen(path, "w");
|
||||
if (!f) return 0;
|
||||
for (int i = 0; i < count; i++)
|
||||
fprintf(f, "%d %d %f %f\n",
|
||||
entries[i].cc, entries[i].controlId,
|
||||
entries[i].min, entries[i].max);
|
||||
fclose(f);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int configLoadCcMappings(const char *deviceName, ConfigCcEntry *entries, int maxCount)
|
||||
{
|
||||
char safe[CONFIG_NAME_LEN];
|
||||
configSanitizeName(deviceName, safe, sizeof(safe));
|
||||
char path[CONFIG_NAME_LEN + 32];
|
||||
snprintf(path, sizeof(path), CONFIG_DIR "/cc_%s.cfg", safe);
|
||||
|
||||
FILE *f = fopen(path, "r");
|
||||
if (!f) return 0;
|
||||
int count = 0;
|
||||
while (count < maxCount) {
|
||||
int cc, id;
|
||||
float mn, mx;
|
||||
if (fscanf(f, "%d %d %f %f\n", &cc, &id, &mn, &mx) != 4) break;
|
||||
if (cc >= 0 && cc < 128) {
|
||||
entries[count].cc = cc;
|
||||
entries[count].controlId = id;
|
||||
entries[count].min = mn;
|
||||
entries[count].max = mx;
|
||||
count++;
|
||||
}
|
||||
}
|
||||
fclose(f);
|
||||
return count;
|
||||
}
|
||||
Reference in New Issue
Block a user