Compare commits
No files matched your search
+2
-1
@@ -8,4 +8,5 @@ toolchain/
|
||||
output/
|
||||
.work/
|
||||
*.luac
|
||||
!示例/*.luac
|
||||
!示例/*.luac
|
||||
*.zip
|
||||
@@ -4,13 +4,18 @@
|
||||
|
||||
- `uid.lua` —— Lua 源码(结构化,可重复执行,幂等)
|
||||
- `uid.luac` —— Lua 5.3 字节码(与游戏端编译器逐字节一致)
|
||||
- `uid.sql` —— 可直接执行进 `t_luashell_config` 的插入语句
|
||||
- `luashell.sql` —— 可直接执行进 `t_luashell_config` 的插入语句
|
||||
- `info.txt` —— 本次生成的参数与字节码头快照
|
||||
|
||||
单文件、纯离线:不联网、不起本地端口、不装运行库、不写注册表。
|
||||
原生免安装、纯离线:不联网、不起本地端口、不装运行库、不写注册表。请保留同目录的游戏专用 `luac.exe`。
|
||||
|
||||

|
||||
|
||||
## 版本
|
||||
|
||||
- **v3.1.0** —— 深灰蓝工具界面:顶部实时预览、左侧分段编辑、右侧结果、底部固定操作;可调预览 UID 与 SQL 主键;自适应窗口、键盘导航与快捷键;修复长预设切换时的内容丢失及分段删除后的残留控件。
|
||||
- **v3.0.1** —— 生成的 SQL 文件名 `uid.sql` → **`luashell.sql`**(内容不变,仍是 `INSERT INTO t_luashell_config`);程序名改为「彩色UID生成器」,作者署名 `by 蓝色大肥鱼`
|
||||
- **v3.0** —— C 原生重写,彻底修掉「点生成·编译就卡死」;单实例、Job + 15s 超时、后台线程编译;体积 2.84 MB → 0.42 MB
|
||||
## 功能
|
||||
|
||||
| 功能 | 说明 |
|
||||
@@ -20,7 +25,11 @@
|
||||
| 颜色输入 | 支持 `#RGB`、`#RRGGBB`、`#RRGGBBAA`,自动规范成大写 |
|
||||
| 两种风格 | 结构化(幂等,推荐)/ 极简单句 |
|
||||
| 冒号 & UID 分色 | 前缀、冒号、UID 三者可分别配色 |
|
||||
| 三个页签 | Lua 源码 / 字节码(十六进制)/ SQL,可复制当前页 |
|
||||
| 四个页签 | Lua 源码 / 字节码(十六进制)/ SQL / 信息,可复制当前页 |
|
||||
| 独立预览 | 顶部更改示例 UID,仅影响预览;生成脚本仍读取游戏中的真实 UID |
|
||||
| SQL 主键 | 结果区底部设置主键,默认 1 |
|
||||
| 自适应布局 | 默认 1280×820、最小 1040×700(逻辑像素);分段行数随高度调整,可滚轮或箭头翻动 |
|
||||
| 键盘操作 | Tab / Shift+Tab 导航、Enter / 空格激活按钮;F5 / Ctrl+Enter 生成,Ctrl+S 保存,Ctrl+1–4 切页 |
|
||||
| 一键保存 | 落到 `程序目录\output\YYYYmmdd-HHMMSS\`,四个文件齐全 |
|
||||
| 后台编译 | 编译在 worker 线程,界面全程可操作,**不会假死** |
|
||||
| 单实例 | 重复双击只把已有窗口叫到前面,不会起第二个进程抢编译目录 |
|
||||
@@ -53,9 +62,9 @@ v3.0 用纯 Win32/GDI 的 C 重写并改掉这条路径:
|
||||
```
|
||||
|
||||
1. 选预设或自己填分段(文字 + 颜色)
|
||||
2. 需要就改冒号色 / UID 色 / 脚本风格
|
||||
2. 需要就改冒号色 / UID 色 / 脚本风格;顶部调整预览 UID,结果区底部设置 SQL 主键
|
||||
3. 点「生成 · 编译」
|
||||
4. 点「保存到磁盘」(输出到 `output\<时间戳>\`),或「复制当前页」
|
||||
4. 点「保存全部文件」(输出到 `output\<时间戳>\`),或「复制当前页」
|
||||
|
||||
### 命令行
|
||||
|
||||
@@ -91,7 +100,7 @@ gcc -O2 -municode -mwindows ^
|
||||
-luser32 -lgdi32 -lshell32 -lmsimg32 -lcomdlg32 -lole32 -ladvapi32 -static
|
||||
```
|
||||
|
||||
`build.bat` 已经封装好(会自己设 `TMP` 到脚本目录,避免中文用户名导致的 `can't create ...ccXXX.o`)。
|
||||
`build.bat` 已封装编译流程,会把 `TMP` 设置到项目的 `tmp` 目录。MinGW 的部分版本无法使用带中文的临时路径,遇到 `can't create ...ccXXX.o` 时,请在全英文路径下构建。
|
||||
|
||||
注意:`lundump.h` 里 `LUAC_FORMAT` 已改成 `1`、`ldump.c` 的 `DumpByte(sizeof(size_t), D);` 已删除,用来对齐游戏端 dump 头(内置编译兜底时才用到)。
|
||||
|
||||
@@ -105,9 +114,13 @@ src\presets.c 五个预设
|
||||
src\luac_in.c 调用 luac.exe(Job + 15s 超时)/ 内置 Lua 编译
|
||||
src\ui_impl.c 自绘界面、布局、绘制
|
||||
src\ui_app.c 窗口过程、控件、点击分派、命令行
|
||||
src\ui_layout.h 可独立测试的自适应布局
|
||||
tests\ 布局与真实 Win32 控件状态回归测试
|
||||
build.bat 一键构建
|
||||
```
|
||||
|
||||
测试方法见 [tests/README.md](tests/README.md)。五个预设的 Lua / 字节码保持原有协议和内容;新版的界面调整不改变生成格式。
|
||||
|
||||
## 常见问题
|
||||
|
||||
**Q:双击没窗口?**
|
||||
@@ -127,3 +140,5 @@ build.bat 一键构建
|
||||
MIT。作者:**蓝色大肥鱼**。
|
||||
|
||||
生成出的 Lua/SQL 由你自己负责在对应环境使用。
|
||||
**Q:生成的 `uid.lua` 第一行注释还写着「由 UID 水印工坊生成」,是不是没改名?**
|
||||
是有意保留的。注释也参与源码长度与字节码,改一个字就会让 `uid.luac` 与游戏端参考产物不再逐字节一致(`--selftest` 会失败)。程序名、窗口标题、作者信息都已改为「彩色UID生成器 / by 蓝色大肥鱼」,只有生成文件里的这行标记保持原样。
|
||||
BIN
Binary file not shown.
|
Before Width: | Height: | Size: 65 KiB After Width: | Height: | Size: 121 KiB |
@@ -11,9 +11,8 @@
|
||||
#define APP_NAME_W L"彩色UID生成器"
|
||||
#define APP_AUTHOR "by 蓝色大肥鱼"
|
||||
#define APP_AUTHOR_W L"by 蓝色大肥鱼"
|
||||
#define APP_VERSION "3.0"
|
||||
#define APP_VERSION "3.1.0"
|
||||
#define MAXSEG 16
|
||||
#define VISROWS 4
|
||||
|
||||
/* ---------- 字符串构造器 ---------- */
|
||||
typedef struct {
|
||||
|
||||
+31
-18
@@ -6,11 +6,8 @@
|
||||
#include "app.h"
|
||||
|
||||
/* ==================================================================== */
|
||||
/* 彩色UID生成器 v3.0 · by 蓝色大肥鱼 —— C 原生版 */
|
||||
/* */
|
||||
/* 和 Go 版最大的区别:Lua 5.3.6 直接编进这个 exe 里,生成/编译全程在 */
|
||||
/* 本进程内完成,不起 luac.exe 子进程、不往 %TEMP% 写可执行文件, */
|
||||
/* 所以安全软件没有可以拦的对象,也就不会再出现「点生成就卡死」。 */
|
||||
/* 彩色UID生成器 · by 蓝色大肥鱼 —— C 原生版 */
|
||||
/* 后台调用随包 luac.exe,失败时回落到内置 Lua;界面线程保持响应。 */
|
||||
/* ==================================================================== */
|
||||
|
||||
#pragma comment(lib, "user32.lib")
|
||||
@@ -23,6 +20,8 @@
|
||||
#define ID_SEG_BASE 2000
|
||||
#define ID_OUT 1005
|
||||
#define ID_TIMER_DEB 77
|
||||
#define ID_PREVIEW_UID 1006
|
||||
#define ID_ROWID 1007
|
||||
|
||||
/* 命中 id */
|
||||
enum {
|
||||
@@ -57,6 +56,9 @@ typedef struct {
|
||||
int scroll;
|
||||
int activePreset;
|
||||
int tab; /* 0 lua, 1 hex, 2 sql, 3 info */
|
||||
int visibleRows;
|
||||
int pressed;
|
||||
int keyboardHit;
|
||||
char *outputs[4];
|
||||
int built;
|
||||
char status[160];
|
||||
@@ -85,19 +87,19 @@ static App *g;
|
||||
/* ------------------------------------------------------------------ */
|
||||
/* 颜色 / 字体 */
|
||||
/* ------------------------------------------------------------------ */
|
||||
#define C_BG_TOP RGB(0x0A, 0x10, 0x1E)
|
||||
#define C_BG_BOT RGB(0x11, 0x1B, 0x30)
|
||||
#define C_CARD RGB(0x13, 0x1A, 0x2A)
|
||||
#define C_CARD2 RGB(0x18, 0x21, 0x33)
|
||||
#define C_BORDER RGB(0x26, 0x31, 0x48)
|
||||
#define C_TEXT RGB(0xE6, 0xED, 0xF7)
|
||||
#define C_DIM RGB(0x8F, 0xA0, 0xB8)
|
||||
#define C_FAINT RGB(0x5B, 0x6B, 0x84)
|
||||
#define C_ACCENT RGB(0x4F, 0x8C, 0xF7)
|
||||
#define C_ACCENT2 RGB(0x8B, 0x5C, 0xF6)
|
||||
#define C_BG_TOP RGB(0x14, 0x17, 0x1D)
|
||||
#define C_BG_BOT RGB(0x14, 0x17, 0x1D)
|
||||
#define C_CARD RGB(0x1B, 0x20, 0x28)
|
||||
#define C_CARD2 RGB(0x23, 0x2A, 0x35)
|
||||
#define C_BORDER RGB(0x35, 0x3F, 0x4E)
|
||||
#define C_TEXT RGB(0xEB, 0xEF, 0xF5)
|
||||
#define C_DIM RGB(0xA6, 0xB2, 0xC3)
|
||||
#define C_FAINT RGB(0x94, 0xA0, 0xB2)
|
||||
#define C_ACCENT RGB(0x42, 0x8C, 0xF5)
|
||||
#define C_ACCENT2 RGB(0x42, 0x8C, 0xF5)
|
||||
#define C_OK RGB(0x34, 0xD3, 0x99)
|
||||
#define C_DANGER RGB(0xF8, 0x71, 0x71)
|
||||
#define C_INPUT RGB(0x0F, 0x16, 0x24)
|
||||
#define C_INPUT RGB(0x12, 0x17, 0x20)
|
||||
|
||||
static int SC(int v) { return MulDiv(v, g->dpi, 96); }
|
||||
|
||||
@@ -122,7 +124,7 @@ static void make_fonts(void)
|
||||
g->fBody = make_font(13, 0, L"Microsoft YaHei UI");
|
||||
g->fSmall = make_font(12, 0, L"Microsoft YaHei UI");
|
||||
g->fMono = make_font(13, 0, L"Consolas");
|
||||
g->fPrev = make_font(19, 1, L"Microsoft YaHei UI");
|
||||
g->fPrev = make_font(22, 1, L"Microsoft YaHei UI");
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------ */
|
||||
@@ -219,6 +221,7 @@ static int g_rc;
|
||||
static int g_fallback;
|
||||
static Req g_jobreq;
|
||||
static char *g_jobsrc;
|
||||
static int g_rebuild_pending;
|
||||
|
||||
static DWORD WINAPI compile_worker(LPVOID param)
|
||||
{
|
||||
@@ -243,6 +246,7 @@ static void finish_build(void)
|
||||
char *src = g_jobsrc;
|
||||
|
||||
if (g_rc != 0) {
|
||||
resp_free(&g->last);
|
||||
g->built = 0;
|
||||
snprintf(g->status, sizeof(g->status), "生成失败");
|
||||
set_output(0, xstrdup(src));
|
||||
@@ -289,6 +293,7 @@ static void finish_build(void)
|
||||
set_output(2, xstrdup(resp.sql));
|
||||
set_output(3, info);
|
||||
|
||||
resp_free(&g->last);
|
||||
g->last = resp;
|
||||
g_code = NULL; /* 所有权交给 last */
|
||||
g->built = 1;
|
||||
@@ -299,7 +304,7 @@ static void finish_build(void)
|
||||
|
||||
static void build_now(void)
|
||||
{
|
||||
if (g_building) return; /* 正在编译就忽略,避免排队堆积 */
|
||||
if (g_building) { g_rebuild_pending=1; return; }
|
||||
Req r = g->req;
|
||||
for (int i = 0; i < r.nseg && i < MAXSEG; i++)
|
||||
memcpy(r.segs[i].color, g_segcolor.color[i], 8);
|
||||
@@ -313,15 +318,23 @@ static void build_now(void)
|
||||
g_jobsrc = gen_lua(&r);
|
||||
g_jobreq = r;
|
||||
g_building = 1;
|
||||
g->built = 0;
|
||||
snprintf(g->status, sizeof(g->status), "编译中…");
|
||||
InvalidateRect(g->hwnd, NULL, FALSE);
|
||||
CreateThread(NULL, 0, compile_worker, NULL, 0, NULL);
|
||||
}
|
||||
|
||||
static void run_build_from_ui(void);
|
||||
|
||||
static void build_done(void)
|
||||
{
|
||||
g_building = 0;
|
||||
finish_build();
|
||||
if (g_rebuild_pending) {
|
||||
g_rebuild_pending=0;
|
||||
KillTimer(g->hwnd,ID_TIMER_DEB);
|
||||
run_build_from_ui();
|
||||
}
|
||||
}
|
||||
void resp_free(Resp *r)
|
||||
{
|
||||
|
||||
+121
-5
@@ -77,6 +77,16 @@ static void run_build_from_ui(void)
|
||||
trim_color(g->req.uidcolor, u, "#58FAF4");
|
||||
free(u);
|
||||
}
|
||||
if(g_hpreview){
|
||||
wchar_t value[32];GetWindowTextW(g_hpreview,value,32);
|
||||
char *utf8=u8_from_w(value);
|
||||
snprintf(g->req.previewUID,sizeof(g->req.previewUID),"%s",utf8);free(utf8);
|
||||
}
|
||||
if(g_hrowid){
|
||||
wchar_t value[16];GetWindowTextW(g_hrowid,value,16);
|
||||
long row=wcstol(value,NULL,10);
|
||||
g->req.rowid=(row>0&&row<=2147483647L)?(int)row:1;
|
||||
}
|
||||
build_now();
|
||||
sync_color_edits();
|
||||
}
|
||||
@@ -94,7 +104,7 @@ static void click(int id)
|
||||
if (g->scroll > 0) { g->scroll--; layout(); InvalidateRect(g->hwnd, NULL, FALSE); }
|
||||
break;
|
||||
case HIT_DOWN:
|
||||
if (g->scroll + VISROWS < g->req.nseg) { g->scroll++; layout(); InvalidateRect(g->hwnd, NULL, FALSE); }
|
||||
if (g->scroll + visible_rows() < g->req.nseg) { g->scroll++; layout(); InvalidateRect(g->hwnd, NULL, FALSE); }
|
||||
break;
|
||||
case HIT_STYLE_RICH:
|
||||
if (g->req.style != 0) { g->req.style = 0; run_build_from_ui(); }
|
||||
@@ -117,6 +127,10 @@ static LRESULT CALLBACK wndproc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp)
|
||||
out_edit_create();
|
||||
g_hcolon = make_edit(hwnd, ID_COLON, 0);
|
||||
g_hucid = make_edit(hwnd, ID_UCID, 0);
|
||||
g_hpreview=make_edit(hwnd,ID_PREVIEW_UID,0);
|
||||
g_hrowid=make_edit(hwnd,ID_ROWID,ES_NUMBER);
|
||||
SendMessageW(g_hpreview,EM_SETLIMITTEXT,31,0);
|
||||
SendMessageW(g_hrowid,EM_SETLIMITTEXT,10,0);
|
||||
{
|
||||
wchar_t *w = w_from_u8(g->req.colon);
|
||||
SetWindowTextW(g_hcolon, w);
|
||||
@@ -142,6 +156,7 @@ static LRESULT CALLBACK wndproc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp)
|
||||
}
|
||||
updating = 0;
|
||||
}
|
||||
sync_option_edits();
|
||||
layout();
|
||||
run_build_from_ui();
|
||||
#ifdef UID_DEBUG_INIT
|
||||
@@ -175,8 +190,10 @@ static LRESULT CALLBACK wndproc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp)
|
||||
|
||||
case WM_GETMINMAXINFO: {
|
||||
MINMAXINFO *mm = (MINMAXINFO *)lp;
|
||||
mm->ptMinTrackSize.x = SC(1000);
|
||||
mm->ptMinTrackSize.y = SC(700);
|
||||
RECT minimum={0,0,SC(1040),SC(700)};
|
||||
AdjustWindowRectEx(&minimum,WS_OVERLAPPEDWINDOW,FALSE,0);
|
||||
mm->ptMinTrackSize.x = minimum.right-minimum.left;
|
||||
mm->ptMinTrackSize.y = minimum.bottom-minimum.top;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -221,12 +238,48 @@ static LRESULT CALLBACK wndproc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp)
|
||||
|
||||
case WM_LBUTTONDOWN: {
|
||||
int x = GET_X_LPARAM(lp), y = GET_Y_LPARAM(lp);
|
||||
g->pressed=0;
|
||||
for (int i = 0; i < g->nhits; i++) {
|
||||
POINT p = { x, y };
|
||||
if (PtInRect(&g->hits[i].r, p)) { click(g->hits[i].id); break; }
|
||||
if (PtInRect(&g->hits[i].r, p)) {
|
||||
g->pressed=g->hits[i].id;g->keyboardHit=g->pressed;SetFocus(hwnd);SetCapture(hwnd);break;
|
||||
}
|
||||
}
|
||||
InvalidateRect(hwnd,NULL,FALSE);
|
||||
return 0;
|
||||
}
|
||||
case WM_LBUTTONUP: {
|
||||
int pressed=g->pressed;g->pressed=0;
|
||||
if(GetCapture()==hwnd)ReleaseCapture();
|
||||
POINT p={GET_X_LPARAM(lp),GET_Y_LPARAM(lp)};
|
||||
for(int i=0;pressed&&i<g->nhits;i++)
|
||||
if(g->hits[i].id==pressed&&PtInRect(&g->hits[i].r,p)){click(pressed);break;}
|
||||
InvalidateRect(hwnd,NULL,FALSE);return 0;
|
||||
}
|
||||
case WM_CAPTURECHANGED:
|
||||
g->pressed=0;InvalidateRect(hwnd,NULL,FALSE);return 0;
|
||||
case WM_SETFOCUS:
|
||||
case WM_KILLFOCUS:
|
||||
InvalidateRect(hwnd,NULL,FALSE);return 0;
|
||||
case WM_MOUSEWHEEL: {
|
||||
POINT p={GET_X_LPARAM(lp),GET_Y_LPARAM(lp)};ScreenToClient(hwnd,&p);
|
||||
RECT region=pixel_rect(ui.editor);
|
||||
if(PtInRect(®ion,p)){
|
||||
g->scroll+=GET_WHEEL_DELTA_WPARAM(wp)>0?-1:1;
|
||||
layout();InvalidateRect(hwnd,NULL,FALSE);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
case WM_DPICHANGED:
|
||||
g->dpi=HIWORD(wp);make_fonts();
|
||||
for(int i=0;i<MAXSEG;i++){
|
||||
if(g->hseg[i])SendMessageW(g->hseg[i],WM_SETFONT,(WPARAM)g->fBody,TRUE);
|
||||
if(g->hcolor[i])SendMessageW(g->hcolor[i],WM_SETFONT,(WPARAM)g->fBody,TRUE);
|
||||
}
|
||||
{HWND edits[]={g_hcolon,g_hucid,g_hpreview,g_hrowid};for(int i=0;i<4;i++)SendMessageW(edits[i],WM_SETFONT,(WPARAM)g->fBody,TRUE);}
|
||||
SendMessageW(g->hout,WM_SETFONT,(WPARAM)g->fMono,TRUE);
|
||||
{RECT *r=(RECT*)lp;SetWindowPos(hwnd,NULL,r->left,r->top,r->right-r->left,r->bottom-r->top,SWP_NOZORDER|SWP_NOACTIVATE);}
|
||||
layout();InvalidateRect(hwnd,NULL,FALSE);return 0;
|
||||
|
||||
case WM_TIMER:
|
||||
if (wp == ID_TIMER_DEB) {
|
||||
@@ -237,7 +290,10 @@ static LRESULT CALLBACK wndproc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp)
|
||||
|
||||
case WM_COMMAND: {
|
||||
int id = LOWORD(wp), code = HIWORD(wp);
|
||||
if (code == EN_CHANGE && !updating) {
|
||||
if(code==EN_SETFOCUS||code==EN_KILLFOCUS)InvalidateRect(hwnd,NULL,FALSE);
|
||||
if (code == EN_CHANGE && !updating && id != ID_OUT) {
|
||||
if(id!=ID_PREVIEW_UID){g->built=0;snprintf(g->status,sizeof(g->status),"修改待生成");}
|
||||
if(id!=ID_PREVIEW_UID&&g_building)g_rebuild_pending=1;
|
||||
if (id >= ID_SEG_BASE && id < ID_SEG_BASE + 100) {
|
||||
req_from_ui();
|
||||
InvalidateRect(hwnd, NULL, FALSE);
|
||||
@@ -249,6 +305,11 @@ static LRESULT CALLBACK wndproc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp)
|
||||
} else if (id == ID_COLON || id == ID_UCID) {
|
||||
InvalidateRect(hwnd, NULL, FALSE);
|
||||
SetTimer(hwnd, ID_TIMER_DEB, 350, NULL);
|
||||
} else if(id==ID_PREVIEW_UID){
|
||||
wchar_t value[32];GetWindowTextW(g_hpreview,value,32);char *u=u8_from_w(value);
|
||||
snprintf(g->req.previewUID,sizeof(g->req.previewUID),"%s",u);free(u);InvalidateRect(hwnd,NULL,FALSE);
|
||||
} else if(id==ID_ROWID){
|
||||
SetTimer(hwnd,ID_TIMER_DEB,350,NULL);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
@@ -278,6 +339,60 @@ static LRESULT CALLBACK wndproc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp)
|
||||
return DefWindowProcW(hwnd, msg, wp, lp);
|
||||
}
|
||||
|
||||
typedef struct { HWND hwnd; int hit; } UiFocusTarget;
|
||||
|
||||
static void append_hit_target(UiFocusTarget *targets,int *count,int id)
|
||||
{
|
||||
for(int i=0;i<g->nhits;i++)if(g->hits[i].id==id){targets[(*count)++]=(UiFocusTarget){g->hwnd,id};return;}
|
||||
}
|
||||
|
||||
static void append_edit_target(UiFocusTarget *targets,int *count,HWND hwnd)
|
||||
{
|
||||
if(hwnd&&IsWindowVisible(hwnd))targets[(*count)++]=(UiFocusTarget){hwnd,0};
|
||||
}
|
||||
|
||||
static void keyboard_tab(int backwards)
|
||||
{
|
||||
UiFocusTarget targets[120];int count=0;
|
||||
append_edit_target(targets,&count,g_hpreview);
|
||||
for(int i=0;i<presets_count();i++)append_hit_target(targets,&count,HIT_PRESET0+i);
|
||||
for(int i=g->scroll;i<g->req.nseg&&i<g->scroll+visible_rows();i++){
|
||||
append_hit_target(targets,&count,HIT_SEGCOLOR+i);
|
||||
append_edit_target(targets,&count,g->hseg[i]);
|
||||
append_edit_target(targets,&count,g->hcolor[i]);
|
||||
append_hit_target(targets,&count,HIT_SEGDEL+i);
|
||||
}
|
||||
append_hit_target(targets,&count,HIT_ADD);append_hit_target(targets,&count,HIT_UP);append_hit_target(targets,&count,HIT_DOWN);
|
||||
append_edit_target(targets,&count,g_hcolon);append_edit_target(targets,&count,g_hucid);
|
||||
append_hit_target(targets,&count,HIT_STYLE_RICH);append_hit_target(targets,&count,HIT_STYLE_SIMPLE);
|
||||
for(int i=0;i<4;i++)append_hit_target(targets,&count,HIT_TAB0+i);
|
||||
append_edit_target(targets,&count,g->hout);append_edit_target(targets,&count,g_hrowid);
|
||||
append_hit_target(targets,&count,HIT_GEN);append_hit_target(targets,&count,HIT_SAVE);
|
||||
append_hit_target(targets,&count,HIT_COPY);append_hit_target(targets,&count,HIT_OPEN);
|
||||
if(!count)return;
|
||||
HWND focused=GetFocus();int current=backwards?0:-1;
|
||||
for(int i=0;i<count;i++)if(targets[i].hwnd==focused&&(focused!=g->hwnd||targets[i].hit==g->keyboardHit)){current=i;break;}
|
||||
int next=(current+count+(backwards?-1:1))%count;
|
||||
g->keyboardHit=targets[next].hit;SetFocus(targets[next].hwnd);InvalidateRect(g->hwnd,NULL,FALSE);
|
||||
}
|
||||
|
||||
static int keyboard_message(MSG *message)
|
||||
{
|
||||
if(message->message!=WM_KEYDOWN)return 0;
|
||||
HWND focused=GetFocus();
|
||||
if(focused!=g->hwnd&&!IsChild(g->hwnd,focused))return 0;
|
||||
int control=(GetKeyState(VK_CONTROL)&0x8000)!=0;
|
||||
if(message->wParam==VK_TAB){keyboard_tab((GetKeyState(VK_SHIFT)&0x8000)!=0);return 1;}
|
||||
if(message->wParam==VK_F5||(control&&message->wParam==VK_RETURN)){run_build_from_ui();return 1;}
|
||||
if(control&&message->wParam=='S'){do_save();return 1;}
|
||||
if(control&&message->wParam>='1'&&message->wParam<='4'){click(HIT_TAB0+(int)message->wParam-'1');return 1;}
|
||||
if(focused==g->hwnd&&(message->wParam==VK_RETURN||message->wParam==VK_SPACE)){
|
||||
for(int i=0;i<g->nhits;i++)if(g->hits[i].id==g->keyboardHit){click(g->keyboardHit);break;}
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------ */
|
||||
/* 命令行:--selftest / --compile / --version */
|
||||
/* ------------------------------------------------------------------ */
|
||||
@@ -471,6 +586,7 @@ int WINAPI wWinMain(HINSTANCE hInst, HINSTANCE hPrev, LPWSTR cmdline, int show)
|
||||
|
||||
MSG msg;
|
||||
while (GetMessageW(&msg, NULL, 0, 0) > 0) {
|
||||
if(keyboard_message(&msg))continue;
|
||||
TranslateMessage(&msg);
|
||||
DispatchMessageW(&msg);
|
||||
}
|
||||
|
||||
+207
-229
@@ -2,11 +2,18 @@
|
||||
/* ui_impl.c —— 界面、消息循环、命令行模式(由 main.c 包含) */
|
||||
/* ==================================================================== */
|
||||
|
||||
static const int CLIENT_W = 1180;
|
||||
static const int CLIENT_H = 780;
|
||||
#include "ui_layout.h"
|
||||
static const int CLIENT_W = 1280;
|
||||
static const int CLIENT_H = 820;
|
||||
static UiLayout ui;
|
||||
static HWND g_hpreview, g_hrowid;
|
||||
|
||||
static const RECT R_LEFT = { 24, 80, 470, 740 };
|
||||
static const RECT R_RIGHT = { 494, 80, 1156, 740 };
|
||||
static RECT pixel_rect(UiRect r)
|
||||
{
|
||||
return (RECT){SC(r.left),SC(r.top),SC(r.right),SC(r.bottom)};
|
||||
}
|
||||
|
||||
static int visible_rows(void) { return g->visibleRows>0 ? g->visibleRows : 4; }
|
||||
|
||||
static const char *TAB_NAMES[4] = { "Lua 源码", "字节码", "SQL", "信息" };
|
||||
|
||||
@@ -32,6 +39,7 @@ static void req_from_ui(void)
|
||||
|
||||
static void seg_set_color_edit(int i);
|
||||
static HWND seg_make(int i);
|
||||
static void sync_option_edits(void);
|
||||
|
||||
static void seg_add(void)
|
||||
{
|
||||
@@ -47,7 +55,7 @@ static void seg_add(void)
|
||||
free(w);
|
||||
seg_set_color_edit(i);
|
||||
updating = 0;
|
||||
if (g->req.nseg > VISROWS) g->scroll = g->req.nseg - VISROWS;
|
||||
if (g->req.nseg > visible_rows()) g->scroll = g->req.nseg - visible_rows();
|
||||
PostMessage(g->hwnd, WM_SIZE, 0, 0);
|
||||
SetFocus(g->hseg[i]);
|
||||
req_from_ui();
|
||||
@@ -76,8 +84,9 @@ static void seg_del(int idx)
|
||||
}
|
||||
int last = g->req.nseg - 1;
|
||||
if (g->hseg[last]) { DestroyWindow(g->hseg[last]); g->hseg[last] = NULL; }
|
||||
if (g->hcolor[last]) { DestroyWindow(g->hcolor[last]); g->hcolor[last] = NULL; }
|
||||
g->req.nseg = last;
|
||||
if (g->scroll > g->req.nseg - VISROWS) g->scroll = g->req.nseg - VISROWS;
|
||||
if (g->scroll > g->req.nseg - visible_rows()) g->scroll = g->req.nseg - visible_rows();
|
||||
if (g->scroll < 0) g->scroll = 0;
|
||||
PostMessage(g->hwnd, WM_SIZE, 0, 0);
|
||||
req_from_ui();
|
||||
@@ -86,6 +95,8 @@ static void seg_del(int idx)
|
||||
|
||||
static void preset_click(int idx)
|
||||
{
|
||||
/* Creating an EDIT also emits EN_CHANGE; keep the complete preset atomic. */
|
||||
updating = 1;
|
||||
preset_apply(&g->req, idx);
|
||||
g->activePreset = idx;
|
||||
/* 重建 16 个编辑框的内容 */
|
||||
@@ -99,12 +110,14 @@ static void preset_click(int idx)
|
||||
free(w);
|
||||
memcpy(g_segcolor.color[i], g->req.segs[i].color, 8);
|
||||
seg_set_color_edit(i);
|
||||
updating = 0;
|
||||
} else if (g->hseg[i]) {
|
||||
DestroyWindow(g->hseg[i]);
|
||||
g->hseg[i] = NULL;
|
||||
if (g->hcolor[i]) { DestroyWindow(g->hcolor[i]); g->hcolor[i]=NULL; }
|
||||
}
|
||||
}
|
||||
sync_option_edits();
|
||||
updating = 0;
|
||||
g->scroll = 0;
|
||||
PostMessage(g->hwnd, WM_SIZE, 0, 0);
|
||||
build_now();
|
||||
@@ -118,10 +131,26 @@ static HWND g_hcolon, g_hucid;
|
||||
|
||||
static void seg_set_color_edit(int i)
|
||||
{
|
||||
if (!g->hseg[i]) return;
|
||||
/* 颜色框是单独的控件,用 id = ID_SEG_BASE+100+i 挂在父窗口上,
|
||||
这里只需要把颜色同步显示到自绘色块上 */
|
||||
(void)i;
|
||||
if (!g->hcolor[i]) return;
|
||||
int was=updating;
|
||||
updating=1;
|
||||
wchar_t *value=w_from_u8(g_segcolor.color[i]);
|
||||
SetWindowTextW(g->hcolor[i],value);
|
||||
free(value);
|
||||
updating=was;
|
||||
}
|
||||
|
||||
static void sync_option_edits(void)
|
||||
{
|
||||
int was=updating;
|
||||
updating=1;
|
||||
wchar_t *value=w_from_u8(g->req.colon);
|
||||
SetWindowTextW(g_hcolon,value); free(value);
|
||||
value=w_from_u8(g->req.uidcolor);
|
||||
SetWindowTextW(g_hucid,value); free(value);
|
||||
if(g_hpreview){ value=w_from_u8(g->req.previewUID);SetWindowTextW(g_hpreview,value);free(value); }
|
||||
if(g_hrowid){ wchar_t number[24];swprintf(number,24,L"%d",g->req.rowid);SetWindowTextW(g_hrowid,number); }
|
||||
updating=was;
|
||||
}
|
||||
|
||||
static void set_toast(const wchar_t *msg)
|
||||
@@ -143,24 +172,29 @@ static void move_child(HWND h, int x, int y, int w, int hh)
|
||||
|
||||
static void layout(void)
|
||||
{
|
||||
for (int i = 0; i < MAXSEG; i++) {
|
||||
if (!g->hseg[i]) continue;
|
||||
int r = i - g->scroll;
|
||||
if (r < 0 || r >= VISROWS) {
|
||||
ShowWindow(g->hseg[i], SW_HIDE);
|
||||
continue;
|
||||
}
|
||||
int y = 274 + r * 40;
|
||||
ShowWindow(g->hseg[i], SW_SHOW);
|
||||
move_child(g->hseg[i], 74, y, 210, 30);
|
||||
if (g->hcolor[i]) {
|
||||
ShowWindow(g->hcolor[i], SW_SHOW);
|
||||
move_child(g->hcolor[i], 292, y, 92, 30);
|
||||
}
|
||||
}
|
||||
if (g_hcolon) move_child(g_hcolon, 126, 496, 110, 30);
|
||||
if (g_hucid) move_child(g_hucid, 344, 496, 100, 30);
|
||||
if (g->hout) move_child(g->hout, 514, 250, 622, 390);
|
||||
RECT client;GetClientRect(g->hwnd,&client);
|
||||
ui=ui_layout(MulDiv(client.right,96,g->dpi),MulDiv(client.bottom,96,g->dpi));
|
||||
g->visibleRows=ui.visible_rows;
|
||||
int maxscroll=g->req.nseg-visible_rows();
|
||||
if(maxscroll<0)maxscroll=0;
|
||||
if(g->scroll>maxscroll)g->scroll=maxscroll;
|
||||
if(g->scroll<0)g->scroll=0;
|
||||
for(int i=0;i<MAXSEG;i++){
|
||||
int row=i-g->scroll;
|
||||
int shown=g->hseg[i] && i<g->req.nseg && row>=0 && row<visible_rows();
|
||||
if(g->hseg[i])ShowWindow(g->hseg[i],shown?SW_SHOW:SW_HIDE);
|
||||
if(g->hcolor[i])ShowWindow(g->hcolor[i],shown?SW_SHOW:SW_HIDE);
|
||||
if(!shown)continue;
|
||||
int y=ui.segment_top+row*40;
|
||||
move_child(g->hseg[i],ui.editor.left+68,y,ui.editor.right-ui.editor.left-224,32);
|
||||
move_child(g->hcolor[i],ui.editor.right-148,y,96,32);
|
||||
}
|
||||
int x=ui.editor.left,y=ui.segment_actions+46;
|
||||
move_child(g_hcolon,x+76,y,96,30);
|
||||
move_child(g_hucid,x+252,y,ui.editor.right-x-272,30);
|
||||
move_child(g_hpreview,ui.preview.right-212,ui.preview.top+61,188,34);
|
||||
move_child(g_hrowid,ui.result.left+92,ui.result.bottom-36,74,26);
|
||||
move_child(g->hout,ui.output.left,ui.output.top,ui.output.right-ui.output.left,ui.output.bottom-ui.output.top);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------ */
|
||||
@@ -168,15 +202,28 @@ static void layout(void)
|
||||
/* ------------------------------------------------------------------ */
|
||||
static int hit_of(int id) { return g->hover == id; }
|
||||
|
||||
static void focus_outline(HDC dc,RECT r,int id)
|
||||
{
|
||||
if(GetFocus()!=g->hwnd || g->keyboardHit!=id)return;
|
||||
InflateRect(&r,-SC(3),-SC(3));
|
||||
HPEN pen=CreatePen(PS_SOLID,SC(1),C_TEXT);
|
||||
HGDIOBJ old=SelectObject(dc,pen),brush=SelectObject(dc,GetStockObject(NULL_BRUSH));
|
||||
RoundRect(dc,r.left,r.top,r.right,r.bottom,SC(8),SC(8));
|
||||
SelectObject(dc,brush);SelectObject(dc,old);DeleteObject(pen);
|
||||
}
|
||||
|
||||
static void draw_button(HDC dc, RECT r, const char *label, int id, int kind)
|
||||
{
|
||||
COLORREF bg = C_CARD2, bd = C_BORDER, fg = C_TEXT;
|
||||
if (kind == 1) { bg = RGB(0x1B, 0x25, 0x3A); bd = RGB(0x35, 0x44, 0x60); }
|
||||
if (kind == 2) { bg = RGB(0x1A, 0x3A, 0x2C); bd = RGB(0x2F, 0x6B, 0x52); fg = C_OK; }
|
||||
if (hit_of(id)) { bg = RGB(0x22, 0x2E, 0x47); bd = C_ACCENT; }
|
||||
round_rect(dc, r, bg, bd, 8);
|
||||
text_center(dc, label, r, g->fBody, fg);
|
||||
add_hit(r, id);
|
||||
int enabled=kind>=0;
|
||||
COLORREF bg=C_CARD2,bd=C_BORDER,fg=C_TEXT;
|
||||
if(kind==1){bg=RGB(38,101,196);bd=RGB(67,132,225);fg=RGB(255,255,255);}
|
||||
if(!enabled){bg=C_CARD;fg=RGB(101,113,130);}
|
||||
if(enabled&&hit_of(id)){bg=kind==1?RGB(48,116,215):RGB(43,55,72);bd=C_ACCENT;}
|
||||
if(enabled&&g->pressed==id)bg=RGB(29,63,109);
|
||||
round_rect(dc,r,bg,bd,7);
|
||||
text_center(dc,label,r,g->fBody,fg);
|
||||
focus_outline(dc,r,id);
|
||||
if(enabled)add_hit(r,id);
|
||||
}
|
||||
|
||||
static void draw_chip(HDC dc, RECT r, const char *label, int id, int active)
|
||||
@@ -187,6 +234,7 @@ static void draw_chip(HDC dc, RECT r, const char *label, int id, int active)
|
||||
if (hit_of(id)) bd = RGB(0x6E, 0x8B, 0xC9);
|
||||
round_rect(dc, r, bg, bd, 8);
|
||||
text_center(dc, label, r, g->fBody, fg);
|
||||
focus_outline(dc,r,id);
|
||||
add_hit(r, id);
|
||||
}
|
||||
|
||||
@@ -198,201 +246,126 @@ static void draw_label(HDC dc, const char *s, int x, int y, int w)
|
||||
|
||||
static void draw_preview(HDC dc, RECT box)
|
||||
{
|
||||
round_rect(dc, box, C_INPUT, C_BORDER, 10);
|
||||
|
||||
/* 内容基线 */
|
||||
int x = box.left + SC(22);
|
||||
int cy = (box.top + box.bottom) / 2;
|
||||
SelectObject(dc, g->fPrev);
|
||||
SetBkMode(dc, TRANSPARENT);
|
||||
|
||||
for (int i = 0; i < g->req.nseg; i++) {
|
||||
const char *t = g->req.segs[i].text;
|
||||
wchar_t *w = w_from_u8(t[0] ? t : " ");
|
||||
SIZE sz = { 0, 0 };
|
||||
GetTextExtentPoint32W(dc, w, (int)wcslen(w), &sz);
|
||||
SetTextColor(dc, parse_color(g->req.segs[i].color));
|
||||
TextOutW(dc, x, cy - sz.cy / 2, w, (int)wcslen(w));
|
||||
x += sz.cx;
|
||||
free(w);
|
||||
}
|
||||
{
|
||||
wchar_t *w = L":";
|
||||
SIZE sz = { 0, 0 };
|
||||
GetTextExtentPoint32W(dc, w, 1, &sz);
|
||||
SetTextColor(dc, parse_color(g->req.colon));
|
||||
TextOutW(dc, x, cy - sz.cy / 2, w, 1);
|
||||
x += sz.cx;
|
||||
}
|
||||
{
|
||||
const char *uid = g->req.previewUID[0] ? g->req.previewUID : "123456789";
|
||||
wchar_t *w = w_from_u8(uid);
|
||||
SIZE sz = { 0, 0 };
|
||||
GetTextExtentPoint32W(dc, w, (int)wcslen(w), &sz);
|
||||
SetTextColor(dc, parse_color(g->req.uidcolor));
|
||||
TextOutW(dc, x, cy - sz.cy / 2, w, (int)wcslen(w));
|
||||
free(w);
|
||||
}
|
||||
round_rect(dc,box,C_INPUT,C_BORDER,7);
|
||||
int saved=SaveDC(dc);
|
||||
IntersectClipRect(dc,box.left+SC(18),box.top+2,box.right-SC(18),box.bottom-2);
|
||||
SelectObject(dc,g->fPrev);
|
||||
int total=0;
|
||||
for(int i=0;i<g->req.nseg;i++){
|
||||
wchar_t *w=w_from_u8(g->req.segs[i].text);SIZE s;
|
||||
GetTextExtentPoint32W(dc,w,(int)wcslen(w),&s);total+=s.cx;free(w);
|
||||
}
|
||||
wchar_t *uid=w_from_u8(g->req.previewUID[0]?g->req.previewUID:"123456789");
|
||||
SIZE tail;GetTextExtentPoint32W(dc,uid,(int)wcslen(uid),&tail);total+=tail.cx+SC(12);
|
||||
HFONT smaller=NULL;
|
||||
if(total>box.right-box.left-SC(40)){
|
||||
int size=MulDiv(22,box.right-box.left-SC(40),total);if(size<11)size=11;
|
||||
smaller=make_font(size,1,L"Microsoft YaHei UI");SelectObject(dc,smaller);
|
||||
}
|
||||
int x=box.left+SC(20),cy=(box.top+box.bottom)/2;
|
||||
SetBkMode(dc,TRANSPARENT);
|
||||
for(int i=0;i<g->req.nseg;i++){
|
||||
wchar_t *w=w_from_u8(g->req.segs[i].text);SIZE s;
|
||||
GetTextExtentPoint32W(dc,w,(int)wcslen(w),&s);
|
||||
SetTextColor(dc,parse_color(g_segcolor.color[i]));
|
||||
TextOutW(dc,x,cy-s.cy/2,w,(int)wcslen(w));x+=s.cx;free(w);
|
||||
}
|
||||
SIZE s;GetTextExtentPoint32W(dc,L":",1,&s);SetTextColor(dc,parse_color(g->req.colon));
|
||||
TextOutW(dc,x,cy-s.cy/2,L":",1);x+=s.cx;
|
||||
GetTextExtentPoint32W(dc,uid,(int)wcslen(uid),&s);SetTextColor(dc,parse_color(g->req.uidcolor));
|
||||
TextOutW(dc,x,cy-s.cy/2,uid,(int)wcslen(uid));free(uid);
|
||||
RestoreDC(dc,saved);if(smaller)DeleteObject(smaller);
|
||||
}
|
||||
|
||||
static void paint(HDC target, int w, int h)
|
||||
static void paint(HDC target,int w,int h)
|
||||
{
|
||||
HDC dc = g->memDC;
|
||||
(void)target;
|
||||
HDC dc=g->memDC;
|
||||
fill_rect(dc,(RECT){0,0,w,h},C_BG_TOP);
|
||||
g->nhits=0;
|
||||
text_at(dc,APP_NAME,(RECT){SC(24),SC(15),SC(600),SC(46)},g->fTitle,C_TEXT,DT_SINGLELINE|DT_VCENTER);
|
||||
text_at(dc,APP_AUTHOR " / 水印编辑工作台",(RECT){SC(25),SC(48),SC(650),SC(68)},g->fSmall,C_DIM,DT_SINGLELINE|DT_VCENTER);
|
||||
int right=ui.width-24;
|
||||
RECT status={SC(right-226),SC(24),SC(right),SC(58)};
|
||||
round_rect(dc,status,C_CARD,C_BORDER,7);
|
||||
COLORREF dot=g_building?C_ACCENT:(g->built?C_OK:C_DIM);
|
||||
fill_rect(dc,(RECT){status.left+SC(12),status.top+SC(13),status.left+SC(20),status.top+SC(21)},dot);
|
||||
const char *status_text=g_building?"正在编译":(g->status[0]?g->status:"就绪");
|
||||
char *toast=NULL;
|
||||
if(g->toast[0]&&GetTickCount()-g->toastAt<4000){toast=u8_from_w(g->toast);status_text=toast;}
|
||||
text_at(dc,status_text,(RECT){status.left+SC(30),status.top,status.right-SC(8),status.bottom},g->fSmall,C_TEXT,DT_SINGLELINE|DT_VCENTER|DT_END_ELLIPSIS);
|
||||
free(toast);
|
||||
|
||||
/* 背景缓存 */
|
||||
if (g->bgDC && (g->bufW != w || g->bufH != h)) {
|
||||
SelectObject(g->bgDC, g->oldBg);
|
||||
DeleteObject(g->bgBmp);
|
||||
DeleteDC(g->bgDC);
|
||||
g->bgDC = NULL;
|
||||
}
|
||||
if (!g->bgDC) {
|
||||
g->bgDC = CreateCompatibleDC(target);
|
||||
g->bgBmp = CreateCompatibleBitmap(target, w, h);
|
||||
g->oldBg = (HBITMAP)SelectObject(g->bgDC, g->bgBmp);
|
||||
for (int y = 0; y < h; y++) {
|
||||
int t = h > 1 ? y * 255 / (h - 1) : 0;
|
||||
COLORREF c = RGB(
|
||||
(GetRValue(C_BG_TOP) * (255 - t) + GetRValue(C_BG_BOT) * t) / 255,
|
||||
(GetGValue(C_BG_TOP) * (255 - t) + GetGValue(C_BG_BOT) * t) / 255,
|
||||
(GetBValue(C_BG_TOP) * (255 - t) + GetBValue(C_BG_BOT) * t) / 255);
|
||||
RECT line = { 0, y, w, y + 1 };
|
||||
fill_rect(g->bgDC, line, c);
|
||||
}
|
||||
}
|
||||
BitBlt(dc, 0, 0, w, h, g->bgDC, 0, 0, SRCCOPY);
|
||||
round_rect(dc,pixel_rect(ui.preview),C_CARD,C_BORDER,10);
|
||||
draw_label(dc,"水印实时预览",ui.preview.left+20,ui.preview.top+14,180);
|
||||
draw_preview(dc,(RECT){SC(ui.preview.left+16),SC(ui.preview.top+44),SC(ui.preview.right-236),SC(ui.preview.bottom-18)});
|
||||
draw_label(dc,"预览 UID",ui.preview.right-212,ui.preview.top+29,188);
|
||||
draw_label(dc,"仅用于展示,不修改真实 UID",ui.preview.right-212,ui.preview.top+101,200);
|
||||
|
||||
g->nhits = 0;
|
||||
round_rect(dc,pixel_rect(ui.editor),C_CARD,C_BORDER,10);
|
||||
round_rect(dc,pixel_rect(ui.result),C_CARD,C_BORDER,10);
|
||||
int ex=ui.editor.left,ey=ui.editor.top,ew=ui.editor.right-ex;
|
||||
text_at(dc,"01 水印编辑",(RECT){SC(ex+20),SC(ey+14),SC(ex+240),SC(ey+38)},g->fH1,C_TEXT,DT_SINGLELINE|DT_VCENTER);
|
||||
char count[40];snprintf(count,sizeof(count),"%d / 16 段",g->req.nseg);
|
||||
text_at(dc,count,(RECT){SC(ui.editor.right-110),SC(ey+17),SC(ui.editor.right-20),SC(ey+35)},g->fSmall,C_DIM,DT_RIGHT|DT_SINGLELINE);
|
||||
const char *names[]={"原神蓝","Boki","GUYU","彩虹","极简白"};
|
||||
int pw=(ew-40-24)/5;
|
||||
for(int i=0;i<presets_count();i++){
|
||||
int x=ex+20+i*(pw+6);
|
||||
draw_chip(dc,(RECT){SC(x),SC(ey+51),SC(x+pw),SC(ey+83)},names[i],HIT_PRESET0+i,g->activePreset==i);
|
||||
}
|
||||
draw_label(dc,"文字分段",ex+68,ui.segment_top-24,180);
|
||||
draw_label(dc,"HEX 颜色",ui.editor.right-148,ui.segment_top-24,100);
|
||||
for(int i=0;i<g->req.nseg;i++){
|
||||
int row=i-g->scroll;if(row<0||row>=visible_rows())continue;
|
||||
int y=ui.segment_top+row*40;
|
||||
RECT sw={SC(ex+20),SC(y+2),SC(ex+52),SC(y+30)};
|
||||
round_rect(dc,sw,parse_color(g_segcolor.color[i]),C_BORDER,5);add_hit(sw,HIT_SEGCOLOR+i);
|
||||
focus_outline(dc,sw,HIT_SEGCOLOR+i);
|
||||
draw_button(dc,(RECT){SC(ui.editor.right-44),SC(y),SC(ui.editor.right-16),SC(y+32)},"×",HIT_SEGDEL+i,g->req.nseg>1?0:-1);
|
||||
}
|
||||
int ay=ui.segment_actions;
|
||||
draw_button(dc,(RECT){SC(ex+20),SC(ay),SC(ex+154),SC(ay+32)},"+ 添加分段",HIT_ADD,g->req.nseg<MAXSEG?0:-1);
|
||||
draw_button(dc,(RECT){SC(ex+164),SC(ay),SC(ex+198),SC(ay+32)},"↑",HIT_UP,g->scroll>0?0:-1);
|
||||
draw_button(dc,(RECT){SC(ex+204),SC(ay),SC(ex+238),SC(ay+32)},"↓",HIT_DOWN,g->scroll+visible_rows()<g->req.nseg?0:-1);
|
||||
char range[40];snprintf(range,sizeof(range),"%d–%d",g->scroll+1,g->scroll+visible_rows()<g->req.nseg?g->scroll+visible_rows():g->req.nseg);
|
||||
text_at(dc,range,(RECT){SC(ex+250),SC(ay),SC(ui.editor.right-20),SC(ay+32)},g->fSmall,C_DIM,DT_RIGHT|DT_SINGLELINE|DT_VCENTER);
|
||||
draw_label(dc,"冒号色",ex+20,ay+51,52);draw_label(dc,"UID 色",ex+194,ay+51,56);
|
||||
draw_label(dc,"脚本风格",ex+20,ay+96,76);
|
||||
draw_chip(dc,(RECT){SC(ex+96),SC(ay+89),SC(ex+244),SC(ay+121)},"结构化 · 幂等",HIT_STYLE_RICH,g->req.style==0);
|
||||
draw_chip(dc,(RECT){SC(ex+252),SC(ay+89),SC(ui.editor.right-20),SC(ay+121)},"极简单句",HIT_STYLE_SIMPLE,g->req.style==1);
|
||||
draw_label(dc,"点色块轮换颜色,或直接输入 HEX",ex+20,ay+132,ew-40);
|
||||
|
||||
/* 标题 */
|
||||
{
|
||||
RECT r = { SC(24), SC(14), SC(700), SC(44) };
|
||||
text_at(dc, APP_NAME, r, g->fTitle, C_TEXT, DT_SINGLELINE | DT_VCENTER);
|
||||
RECT r2 = { SC(24), SC(44), SC(760), SC(62) };
|
||||
char sub[128];
|
||||
snprintf(sub, sizeof(sub), APP_AUTHOR " · v%s · C 原生版 · Lua 5.3.6 · 后台线程编译", APP_VERSION);
|
||||
text_at(dc, sub, r2, g->fSmall, C_FAINT, DT_SINGLELINE | DT_VCENTER);
|
||||
}
|
||||
int rx=ui.result.left,ry=ui.result.top;
|
||||
text_at(dc,"02 生成结果",(RECT){SC(rx+20),SC(ry+14),SC(rx+260),SC(ry+38)},g->fH1,C_TEXT,DT_SINGLELINE|DT_VCENTER);
|
||||
text_at(dc,luac_exe_path()?"luac.exe 已就绪":"内置编译器",(RECT){SC(ui.result.right-192),SC(ry+18),SC(ui.result.right-20),SC(ry+37)},g->fSmall,luac_exe_path()?C_OK:C_DIM,DT_RIGHT|DT_SINGLELINE);
|
||||
int tw=(ui.result.right-rx-40-18)/4;
|
||||
for(int i=0;i<4;i++){
|
||||
int x=rx+20+i*(tw+6);
|
||||
draw_chip(dc,(RECT){SC(x),SC(ry+56),SC(x+tw),SC(ry+90)},TAB_NAMES[i],HIT_TAB0+i,g->tab==i);
|
||||
}
|
||||
draw_label(dc,"SQL 主键",rx+20,ui.result.bottom-31,72);
|
||||
char info[140];
|
||||
if(g->built)snprintf(info,sizeof(info),"Lua %d B · LUAC %d B",g->last.luaBytes,g->last.codeBytes);
|
||||
else snprintf(info,sizeof(info),g_building?"正在生成最新内容…":"编辑后自动生成");
|
||||
text_at(dc,info,(RECT){SC(rx+184),SC(ui.result.bottom-37),SC(ui.result.right-20),SC(ui.result.bottom-12)},g->fSmall,C_DIM,DT_SINGLELINE|DT_RIGHT|DT_VCENTER);
|
||||
|
||||
/* 状态胶囊 */
|
||||
{
|
||||
RECT r = { SC(940), SC(16), SC(1156), SC(50) };
|
||||
int ok = g->built;
|
||||
COLORREF dot = g->status[0] ? (ok ? C_OK : C_DANGER) : C_FAINT;
|
||||
round_rect(dc, r, C_CARD, C_BORDER, 10);
|
||||
RECT d = { r.left + SC(14), r.top + SC(13), r.left + SC(24), r.top + SC(23) };
|
||||
fill_rect(dc, d, dot);
|
||||
RECT tr = { r.left + SC(32), r.top, r.right - SC(8), r.bottom };
|
||||
const char *label = g->status[0] ? g->status : "就绪";
|
||||
if (g->toast[0] && GetTickCount() - g->toastAt < 4000) {
|
||||
char *u = u8_from_w(g->toast);
|
||||
text_at(dc, u, tr, g->fSmall, RGB(0xCF, 0xE1, 0xFF), DT_SINGLELINE | DT_VCENTER);
|
||||
free(u);
|
||||
} else {
|
||||
text_at(dc, label, tr, g->fSmall, ok ? RGB(0xB6, 0xF3, 0xDE) : C_DIM,
|
||||
DT_SINGLELINE | DT_VCENTER);
|
||||
}
|
||||
}
|
||||
|
||||
/* 两张卡片 */
|
||||
round_rect(dc, (RECT){ SC(R_LEFT.left), SC(R_LEFT.top), SC(R_LEFT.right), SC(R_LEFT.bottom) },
|
||||
C_CARD, C_BORDER, 14);
|
||||
round_rect(dc, (RECT){ SC(R_RIGHT.left), SC(R_RIGHT.top), SC(R_RIGHT.right), SC(R_RIGHT.bottom) },
|
||||
C_CARD, C_BORDER, 14);
|
||||
|
||||
draw_label(dc, "预设方案", 44, 96, 300);
|
||||
{
|
||||
const Preset *ps = presets_all();
|
||||
int n = presets_count();
|
||||
for (int i = 0; i < n; i++) {
|
||||
int col = i % 2, row = i / 2;
|
||||
RECT r = { SC(44 + col * 210), SC(120 + row * 40), SC(44 + col * 210 + 196), SC(120 + row * 40 + 34) };
|
||||
draw_button(dc, r, ps[i].name, HIT_PRESET0 + i, g->activePreset == i ? 1 : 0);
|
||||
}
|
||||
}
|
||||
|
||||
draw_label(dc, "前缀分段(文字 / 颜色)", 44, 250, 400);
|
||||
|
||||
/* 色块 + 删除按钮 */
|
||||
for (int i = 0; i < g->req.nseg; i++) {
|
||||
int r = i - g->scroll;
|
||||
if (r < 0 || r >= VISROWS) continue;
|
||||
int y = 274 + r * 40;
|
||||
RECT sw = { SC(44), SC(y + 1), SC(68), SC(y + 29) };
|
||||
round_rect(dc, sw, parse_color(g_segcolor.color[i]), C_BORDER, 6);
|
||||
add_hit(sw, HIT_SEGCOLOR + i);
|
||||
RECT del = { SC(392), SC(y), SC(426), SC(y + 30) };
|
||||
draw_button(dc, del, "✕", HIT_SEGDEL + i, 0);
|
||||
}
|
||||
|
||||
draw_button(dc, (RECT){ SC(44), SC(446), SC(194), SC(478) }, "+ 添加分段", HIT_ADD, 0);
|
||||
draw_button(dc, (RECT){ SC(204), SC(446), SC(248), SC(478) }, "▲", HIT_UP, 0);
|
||||
draw_button(dc, (RECT){ SC(258), SC(446), SC(302), SC(478) }, "▼", HIT_DOWN, 0);
|
||||
|
||||
draw_label(dc, "冒号色", 44, 496, 80);
|
||||
draw_label(dc, "UID 色", 250, 496, 84);
|
||||
draw_label(dc, "脚本风格", 44, 546, 80);
|
||||
draw_chip(dc, (RECT){ SC(126), SC(546), SC(276), SC(578) }, "结构化(幂等)", HIT_STYLE_RICH, g->req.style == 0);
|
||||
draw_chip(dc, (RECT){ SC(286), SC(546), SC(406), SC(578) }, "极简单句", HIT_STYLE_SIMPLE, g->req.style == 1);
|
||||
|
||||
{
|
||||
RECT hr = { SC(44), SC(600), SC(446), SC(720) };
|
||||
text_at(dc,
|
||||
"· 编译在后台线程进行,窗口全程可操作,不会假死\r\n"
|
||||
"· 编译用随包的 luac.exe(与本程序同目录),产物与官方逐字节一致\r\n"
|
||||
"· 注入前请先退出游戏;脚本可重复执行(幂等)",
|
||||
hr, g->fSmall, C_FAINT, DT_LEFT | DT_TOP | DT_WORDBREAK);
|
||||
}
|
||||
|
||||
/* 右卡 */
|
||||
draw_label(dc, "预览", 514, 96, 200);
|
||||
draw_preview(dc, (RECT){ SC(514), SC(118), SC(1136), SC(190) });
|
||||
|
||||
for (int i = 0; i < 4; i++) {
|
||||
RECT r = { SC(514 + i * 140), SC(206), SC(514 + i * 140 + 130), SC(238) };
|
||||
draw_chip(dc, r, TAB_NAMES[i], HIT_TAB0 + i, g->tab == i);
|
||||
}
|
||||
|
||||
/* 主按钮:渐变 */
|
||||
{
|
||||
RECT r = { SC(514), SC(654), SC(664), SC(694) };
|
||||
POINT pts[3] = { { r.left, r.top }, { r.right, r.top }, { r.left, r.bottom } };
|
||||
TRIVERTEX v[3] = {
|
||||
{ r.left, r.top, 0x4F00, 0x8C00, 0xF700, 0xFF00 },
|
||||
{ r.right, r.bottom, 0x8B00, 0x5C00, 0xF600, 0xFF00 },
|
||||
{ 0, 0, 0, 0, 0, 0 }
|
||||
};
|
||||
(void)pts;
|
||||
GRADIENT_RECT gr = { 0, 1 };
|
||||
GradientFill(dc, v, 2, &gr, 1, GRADIENT_FILL_RECT_H);
|
||||
HPEN p = CreatePen(PS_SOLID, 1, RGB(0x9A, 0xAF, 0xD8));
|
||||
HGDIOBJ op = SelectObject(dc, p);
|
||||
HGDIOBJ ob = SelectObject(dc, GetStockObject(NULL_BRUSH));
|
||||
RoundRect(dc, r.left, r.top, r.right, r.bottom, 16, 16);
|
||||
SelectObject(dc, ob);
|
||||
SelectObject(dc, op);
|
||||
DeleteObject(p);
|
||||
text_center(dc, "生成 · 编译", r, g->fH1, RGB(255, 255, 255));
|
||||
add_hit(r, HIT_GEN);
|
||||
}
|
||||
|
||||
draw_button(dc, (RECT){ SC(676), SC(654), SC(826), SC(694) }, "保存到磁盘", HIT_SAVE, 0);
|
||||
draw_button(dc, (RECT){ SC(838), SC(654), SC(968), SC(694) }, "打开目录", HIT_OPEN, 0);
|
||||
draw_button(dc, (RECT){ SC(980), SC(654), SC(1136), SC(694) }, "复制当前页", HIT_COPY, 0);
|
||||
|
||||
if (g->built) {
|
||||
char line[256];
|
||||
snprintf(line, sizeof(line), "源码 %d 字节 · 字节码 %d 字节 · 段数 %d · %s",
|
||||
g->last.luaBytes, g->last.codeBytes, g->req.nseg,
|
||||
g->req.style == 1 ? "极简单句" : "结构化");
|
||||
RECT r = { SC(514), SC(700), SC(1136), SC(722) };
|
||||
text_at(dc, line, r, g->fSmall, C_FAINT, DT_SINGLELINE | DT_VCENTER);
|
||||
}
|
||||
|
||||
/* 提示条(toast) */
|
||||
if (g->toast[0] && GetTickCount() - g->toastAt < 4000) {
|
||||
/* 已画在状态胶囊里 */
|
||||
}
|
||||
int ty=ui.toolbar.top;
|
||||
draw_button(dc,(RECT){SC(24),SC(ty),SC(182),SC(ty+44)},g_building?"编译中…":"生成 · 编译",HIT_GEN,g_building?-1:1);
|
||||
draw_button(dc,(RECT){SC(194),SC(ty),SC(338),SC(ty+44)},"保存全部文件",HIT_SAVE,g->built?0:-1);
|
||||
draw_button(dc,(RECT){SC(350),SC(ty),SC(494),SC(ty+44)},"复制当前页",HIT_COPY,g->built?0:-1);
|
||||
draw_button(dc,(RECT){SC(right-136),SC(ty),SC(right),SC(ty+44)},"打开输出目录",HIT_OPEN,0);
|
||||
text_at(dc,"F5 生成 / Ctrl+S 保存",(RECT){SC(514),SC(ty),SC(right-152),SC(ty+44)},g->fSmall,C_DIM,DT_SINGLELINE|DT_VCENTER);
|
||||
HWND inputs[2*MAXSEG+5];int n=0;
|
||||
inputs[n++]=g_hpreview;inputs[n++]=g_hcolon;inputs[n++]=g_hucid;inputs[n++]=g_hrowid;inputs[n++]=g->hout;
|
||||
for(int i=0;i<MAXSEG;i++){inputs[n++]=g->hseg[i];inputs[n++]=g->hcolor[i];}
|
||||
for(int i=0;i<n;i++){
|
||||
if(!inputs[i]||!IsWindowVisible(inputs[i]))continue;
|
||||
RECT r;GetWindowRect(inputs[i],&r);MapWindowPoints(NULL,g->hwnd,(POINT*)&r,2);InflateRect(&r,SC(2),SC(2));
|
||||
HPEN p=CreatePen(PS_SOLID,SC(1),GetFocus()==inputs[i]?C_ACCENT:C_BORDER);
|
||||
HGDIOBJ old=SelectObject(dc,p),brush=SelectObject(dc,GetStockObject(NULL_BRUSH));
|
||||
Rectangle(dc,r.left,r.top,r.right,r.bottom);SelectObject(dc,brush);SelectObject(dc,old);DeleteObject(p);
|
||||
}
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------ */
|
||||
@@ -401,7 +374,7 @@ static void paint(HDC target, int w, int h)
|
||||
static HWND make_edit(HWND parent, int id, DWORD extra)
|
||||
{
|
||||
HWND h = CreateWindowExW(0, L"EDIT", L"",
|
||||
WS_CHILD | WS_VISIBLE | ES_AUTOHSCROLL | extra,
|
||||
WS_CHILD | WS_VISIBLE | WS_TABSTOP | ES_AUTOHSCROLL | extra,
|
||||
0, 0, 10, 10, parent, (HMENU)(INT_PTR)id, GetModuleHandleW(NULL), NULL);
|
||||
SendMessageW(h, WM_SETFONT, (WPARAM)g->fBody, TRUE);
|
||||
return h;
|
||||
@@ -410,6 +383,8 @@ static HWND make_edit(HWND parent, int id, DWORD extra)
|
||||
|
||||
static HWND seg_make(int i)
|
||||
{
|
||||
int was = updating;
|
||||
updating = 1;
|
||||
HWND h = make_edit(g->hwnd, ID_SEG_BASE + i, 0);
|
||||
if (!g->hcolor[i]) {
|
||||
g->hcolor[i] = make_edit(g->hwnd, ID_SEG_BASE + 100 + i, 0);
|
||||
@@ -417,13 +392,14 @@ static HWND seg_make(int i)
|
||||
SetWindowTextW(g->hcolor[i], w);
|
||||
free(w);
|
||||
}
|
||||
updating = was;
|
||||
return h;
|
||||
}
|
||||
|
||||
static void out_edit_create(void)
|
||||
{
|
||||
g->hout = CreateWindowExW(WS_EX_CLIENTEDGE, L"EDIT", L"",
|
||||
WS_CHILD | WS_VISIBLE | WS_VSCROLL | ES_MULTILINE | ES_READONLY | ES_AUTOVSCROLL | ES_NOHIDESEL,
|
||||
g->hout = CreateWindowExW(0, L"EDIT", L"",
|
||||
WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_VSCROLL | WS_HSCROLL | ES_AUTOHSCROLL | ES_MULTILINE | ES_READONLY | ES_AUTOVSCROLL | ES_NOHIDESEL,
|
||||
0, 0, 10, 10, g->hwnd, (HMENU)ID_OUT, GetModuleHandleW(NULL), NULL);
|
||||
SendMessageW(g->hout, WM_SETFONT, (WPARAM)g->fMono, TRUE);
|
||||
}
|
||||
@@ -463,7 +439,7 @@ static int write_file(const wchar_t *path, const void *data, size_t len)
|
||||
|
||||
static void do_save(void)
|
||||
{
|
||||
if (!g->built) {
|
||||
if (!g->built || g_building) {
|
||||
set_toast(L"还没有生成成功,先点「生成 · 编译」");
|
||||
return;
|
||||
}
|
||||
@@ -482,7 +458,7 @@ static void do_save(void)
|
||||
ok &= write_file(p, g->outputs[0], strlen(g->outputs[0] ? g->outputs[0] : ""));
|
||||
swprintf(p, MAX_PATH, L"%s\\uid.luac", dir);
|
||||
ok &= write_file(p, g->last.code, (size_t)g->last.codeBytes);
|
||||
swprintf(p, MAX_PATH, L"%s\\uid.sql", dir);
|
||||
swprintf(p, MAX_PATH, L"%s\\luashell.sql", dir);
|
||||
ok &= write_file(p, g->outputs[2], strlen(g->outputs[2] ? g->outputs[2] : ""));
|
||||
swprintf(p, MAX_PATH, L"%s\\info.txt", dir);
|
||||
ok &= write_file(p, g->outputs[3], strlen(g->outputs[3] ? g->outputs[3] : ""));
|
||||
@@ -500,6 +476,8 @@ static void do_open_dir(void)
|
||||
|
||||
static void do_copy(void)
|
||||
{
|
||||
if(!g->built || g_building){set_toast(L"请等待最新内容生成完成");return;}
|
||||
|
||||
const char *t = g->outputs[g->tab] ? g->outputs[g->tab] : "";
|
||||
wchar_t *w = w_from_u8(t);
|
||||
size_t n = (wcslen(w) + 1) * sizeof(wchar_t);
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
#ifndef UIDSTUDIO_UI_LAYOUT_H
|
||||
#define UIDSTUDIO_UI_LAYOUT_H
|
||||
|
||||
typedef struct { int left, top, right, bottom; } UiRect;
|
||||
typedef struct {
|
||||
int width, height, segment_top, segment_actions, visible_rows;
|
||||
UiRect preview, editor, result, output, toolbar;
|
||||
} UiLayout;
|
||||
|
||||
static UiLayout ui_layout(int width, int height)
|
||||
{
|
||||
UiLayout l = {0};
|
||||
int editor_width = 400+(width-1040)/5;
|
||||
if (editor_width>480) editor_width=480;
|
||||
if (editor_width<400) editor_width=400;
|
||||
l.width=width; l.height=height;
|
||||
l.preview=(UiRect){24,84,width-24,214};
|
||||
l.toolbar=(UiRect){24,height-72,width-24,height-28};
|
||||
l.editor=(UiRect){24,234,24+editor_width,height-88};
|
||||
l.result=(UiRect){l.editor.right+20,234,width-24,height-88};
|
||||
l.output=(UiRect){l.result.left+20,l.result.top+104,l.result.right-20,l.result.bottom-48};
|
||||
l.segment_top=l.editor.top+132;
|
||||
l.segment_actions=l.editor.bottom-154;
|
||||
l.visible_rows=(l.segment_actions-8-l.segment_top)/40;
|
||||
if(l.visible_rows<2)l.visible_rows=2;
|
||||
if(l.visible_rows>16)l.visible_rows=16;
|
||||
return l;
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,18 @@
|
||||
# Native UI regression checks
|
||||
|
||||
Run from an ASCII-only checkout path with MinGW-w64 GCC on PATH. The Lua source and game-specific luac.exe requirements are the same as the main build. Commands below use PowerShell. Set TMP, TEMP and TMPDIR to an existing writable ASCII-only directory if needed.
|
||||
|
||||
```powershell
|
||||
gcc -O2 -I src tests/test_ui_layout.c -o tests/test_ui_layout.exe
|
||||
./tests/test_ui_layout.exe
|
||||
|
||||
$lua = (Get-ChildItem lua-5.3.6/src/*.c | Where-Object Name -NotIn 'lua.c','luac.c').FullName
|
||||
gcc -O2 -DUNICODE -D_UNICODE -I src -I lua-5.3.6/src tests/test_ui_state.c src/gen.c src/presets.c src/luac_in.c $lua -o tests/test_ui_state.exe -luser32 -lgdi32 -lshell32 -lmsimg32 -lcomdlg32 -lole32 -ladvapi32 -static
|
||||
./tests/test_ui_state.exe
|
||||
```
|
||||
|
||||
The layout test checks panel alignment, output area, visible segment rows and toolbar spacing at five sizes from 1040×700 to 1920×1080.
|
||||
|
||||
The state test creates a separate hidden Win32 window using the real application controls and worker. It checks six preset transitions including 4→13→1 segments, compares the generated Lua with the selected preset, checks the 16-segment limit and deleted control cleanup, edits the SQL row ID, and verifies preview-only changes leave Lua output unchanged. It writes no user export files and does not interact with another running application instance.
|
||||
|
||||
Also run the built application's --selftest with the matching luac.exe next to it. The expected preset bytecode sizes remain 2384 / 2360 / 2348 / 2688 / 2271 bytes. During this UI redesign each of the five bytecode files was SHA-256 compared with the original v3.0.1 build.
|
||||
@@ -0,0 +1,28 @@
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include "ui_layout.h"
|
||||
|
||||
static int width(UiRect r) { return r.right-r.left; }
|
||||
static int height(UiRect r) { return r.bottom-r.top; }
|
||||
|
||||
int main(void)
|
||||
{
|
||||
const int sizes[][2] = {{1040,700},{1180,780},{1280,820},{1600,1000},{1920,1080}};
|
||||
for (unsigned i=0;i<sizeof(sizes)/sizeof(sizes[0]);i++) {
|
||||
UiLayout l = ui_layout(sizes[i][0],sizes[i][1]);
|
||||
assert(l.preview.left==24 && l.preview.right==l.width-24);
|
||||
assert(l.editor.left==24 && l.result.right==l.width-24);
|
||||
assert(l.editor.right+20==l.result.left);
|
||||
assert(l.preview.bottom+20==l.editor.top);
|
||||
assert(l.editor.bottom==l.result.bottom);
|
||||
assert(l.editor.bottom+16<=l.toolbar.top);
|
||||
assert(width(l.output)>=500 && height(l.output)>=200);
|
||||
assert(l.output.left>l.result.left && l.output.right<l.result.right);
|
||||
assert(l.output.bottom<l.result.bottom);
|
||||
assert(l.visible_rows>=2 && l.visible_rows<=16);
|
||||
assert(l.segment_top+l.visible_rows*40<=l.segment_actions-8);
|
||||
assert(l.toolbar.right<=l.width-24 && height(l.toolbar)>=40);
|
||||
printf("PASS %dx%d: %d visible segment rows\n",l.width,l.height,l.visible_rows);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
#include <assert.h>
|
||||
#define wWinMain uid_application_main
|
||||
#define WinMain uid_application_legacy_main
|
||||
#include "../src/main.c"
|
||||
#undef wWinMain
|
||||
#undef WinMain
|
||||
|
||||
static void wait_for_build(void)
|
||||
{
|
||||
DWORD start=GetTickCount();
|
||||
while(g_building){
|
||||
MSG message;
|
||||
while(PeekMessageW(&message,NULL,0,0,PM_REMOVE)){
|
||||
TranslateMessage(&message);DispatchMessageW(&message);
|
||||
}
|
||||
assert(GetTickCount()-start<20000);
|
||||
Sleep(1);
|
||||
}
|
||||
assert(g->built);
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
g=calloc(1,sizeof(App));g->dpi=96;make_fonts();
|
||||
WNDCLASSW wc={0};wc.lpfnWndProc=wndproc;wc.hInstance=GetModuleHandleW(NULL);
|
||||
wc.lpszClassName=L"UIDStateRegression";assert(RegisterClassW(&wc));
|
||||
assert(CreateWindowW(wc.lpszClassName,L"UID state tests",WS_OVERLAPPEDWINDOW,
|
||||
0,0,1280,820,NULL,NULL,wc.hInstance,NULL));
|
||||
wait_for_build();
|
||||
const int sequence[]={3,4,1,2,0,3};
|
||||
for(unsigned k=0;k<sizeof(sequence)/sizeof(sequence[0]);k++){
|
||||
Req expected={0};preset_apply(&expected,sequence[k]);req_normalize(&expected,NULL);
|
||||
preset_click(sequence[k]);req_from_ui();wait_for_build();
|
||||
char *source=gen_lua(&expected);
|
||||
assert(g->req.nseg==expected.nseg);
|
||||
assert(strcmp(source,g->outputs[0])==0);free(source);
|
||||
for(int i=0;i<MAXSEG;i++){
|
||||
assert((g->hseg[i]!=NULL)==(i<expected.nseg));
|
||||
assert((g->hcolor[i]!=NULL)==(i<expected.nseg));
|
||||
}
|
||||
printf("PASS preset switch %d: %d segments and matching Lua output\n",sequence[k],expected.nseg);
|
||||
}
|
||||
while(g->req.nseg<MAXSEG){seg_add();wait_for_build();}
|
||||
seg_add();assert(g->req.nseg==MAXSEG);
|
||||
seg_del(4);wait_for_build();assert(g->req.nseg==MAXSEG-1);
|
||||
assert(!g->hseg[MAXSEG-1]&&!g->hcolor[MAXSEG-1]);
|
||||
SetWindowTextW(g_hrowid,L"7");run_build_from_ui();wait_for_build();
|
||||
assert(g->req.rowid==7);
|
||||
assert(strstr(g->outputs[2],"VALUES (7,"));
|
||||
SetWindowTextW(g->hseg[0],L"First edit");run_build_from_ui();
|
||||
SetWindowTextW(g->hseg[0],L"Latest edit");
|
||||
SetWindowTextW(g->hcolor[0],L"#00AABB");
|
||||
SetWindowTextW(g_hrowid,L"9");wait_for_build();
|
||||
assert(strstr(g->outputs[0],"Latest edit"));
|
||||
assert(strstr(g->outputs[0],"#00AABB"));
|
||||
assert(strstr(g->outputs[2],"VALUES (9,"));
|
||||
puts("PASS edits made during compilation produce the latest complete output");
|
||||
char *previous=xstrdup(g->outputs[0]);
|
||||
SetWindowTextW(g_hpreview,L"987654321");
|
||||
assert(strcmp(g->req.previewUID,"987654321")==0);
|
||||
assert(strcmp(previous,g->outputs[0])==0);free(previous);
|
||||
puts("PASS segment limits, delete cleanup, SQL row ID and preview isolation");
|
||||
const int sizes[][2]={{1040,700},{1180,780},{1280,820},{1600,1000},{1920,1080}};
|
||||
for(unsigned i=0;i<sizeof(sizes)/sizeof(sizes[0]);i++){
|
||||
RECT frame={0,0,sizes[i][0],sizes[i][1]};
|
||||
AdjustWindowRect(&frame,WS_OVERLAPPEDWINDOW,FALSE);
|
||||
SetWindowPos(g->hwnd,NULL,0,0,frame.right-frame.left,frame.bottom-frame.top,SWP_NOZORDER);
|
||||
layout();RECT actual;GetWindowRect(g->hout,&actual);
|
||||
MapWindowPoints(NULL,g->hwnd,(POINT*)&actual,2);
|
||||
assert(actual.left==ui.output.left&&actual.right==ui.output.right);
|
||||
assert(actual.top==ui.output.top&&actual.bottom==ui.output.bottom);
|
||||
assert(g->visibleRows==ui_layout(sizes[i][0],sizes[i][1]).visible_rows);
|
||||
printf("PASS native child control bounds %dx%d\n",sizes[i][0],sizes[i][1]);
|
||||
}
|
||||
DestroyWindow(g->hwnd);
|
||||
return 0;
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
彩色UID生成器 v3.0(C 原生版)· by 蓝色大肥鱼
|
||||
彩色UID生成器 v3.0.1(C 原生版)· by 蓝色大肥鱼
|
||||
=====================================
|
||||
|
||||
一个单文件小工具:把「发给私服 / 客户端」的 UID 水印改成任意彩色富文本,
|
||||
@@ -12,24 +12,27 @@
|
||||
1. 双击 彩色UID生成器.exe,直接弹出窗口。
|
||||
※ 同目录的 luac.exe 请不要删、不要改名,编译要用它。
|
||||
2. 左边选一个预设(原神蓝 / Boki 剧情服 / GUYU-ys3.4 / 彩虹 / 极简白),
|
||||
也可以自己改每段的文字和颜色(点色块会打开系统取色器)。
|
||||
右边实时显示改造后的效果。
|
||||
也可以自己改每段的文字和颜色(点色块轮换常用颜色,或直接填 HEX)。
|
||||
顶部实时显示效果,预览 UID 可以单独修改,不影响游戏里的真实 UID。
|
||||
3. 点「生成 · 编译」,然后在上面四个页签里取结果:
|
||||
Lua 源码 —— 可读的 lua,想手改就用它
|
||||
字节码 —— luac 5.3.6 编出来的字节码 HEX
|
||||
SQL —— 可直接执行的 INSERT INTO t_luashell_config ...
|
||||
信息 —— Lua 版本、源码/字节码大小、段数、脚本风格、字节码头
|
||||
点「复制当前页」拿走,或点「保存到磁盘」写到 output\<时间戳>\ 目录:
|
||||
uid.lua / uid.luac / uid.sql / info.txt
|
||||
点「复制当前页」拿走,或点「保存全部文件」写到 output\<时间戳>\ 目录:
|
||||
uid.lua / uid.luac / luashell.sql / info.txt
|
||||
|
||||
|
||||
二、界面小提示
|
||||
-------------------------------------
|
||||
· 分段最多 16 段;多于 4 段时,分段区域可以鼠标滚轮上下滚。
|
||||
· 分段最多 16 段;可见行数随窗口高度变化,鼠标滚轮或上下箭头可翻动。
|
||||
· 顶部预览、左侧编辑、右侧结果、底部操作;最小窗口为 1040×700 逻辑像素。
|
||||
· Tab / Shift+Tab 切换焦点,Enter / 空格激活按钮;F5 或 Ctrl+Enter 生成。
|
||||
· Ctrl+S 保存全部文件,Ctrl+1 / 2 / 3 / 4 切换结果页签。
|
||||
· 「结构化(幂等)」适合长期用:重复执行不会叠加标签。
|
||||
「极简单句」生成的 lua 更短,适合一次性用。
|
||||
· 「SQL 主键 id」默认 1,插库时别和已有行冲突。
|
||||
· 「打开目录」直接打开保存产物的文件夹。
|
||||
· 「打开输出目录」直接打开保存产物的文件夹。
|
||||
|
||||
|
||||
三、把结果塞进游戏
|
||||
@@ -114,3 +117,5 @@ A: 一般是分段为空或颜色格式不对;点「信息」页签看具体
|
||||
2384 / 2360 / 2348 / 2688 / 2271 字节),生成的 lua / sql 格式也一模一样。
|
||||
|
||||
如果你手上还有旧版,直接覆盖就行;记得把 luac.exe 一起放进来。
|
||||
|
||||
注:生成的 uid.lua 首行注释仍为「由 UID 水印工坊生成(Lua 5.3)」,这是为了与游戏端参考字节码逐字节一致,不要手动改。
|
||||
Reference in new issue
Block a user