Skip to content

Commit cf456a6

Browse files
Merge pull request #376 from OpenWebGAL/dev
4.5.12
2 parents e87550a + f24bf59 commit cf456a6

File tree

76 files changed

+4950
-6464
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+4950
-6464
lines changed

.github/workflows/build-terre.yml

Lines changed: 3 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ jobs:
3636
path: release/WebGAL_Terre_Linux.zip
3737
build-arm64:
3838
name: Build Linux ARM64 Binary
39-
runs-on: ubuntu-latest
39+
runs-on: ubuntu-24.04-arm
4040
steps:
4141
- name: Checkout
4242
uses: actions/checkout@v4
@@ -45,79 +45,10 @@ jobs:
4545
with:
4646
node-version-file: package.json
4747
cache: 'yarn'
48-
- name: Build Stage 1
49-
run: |
50-
echo "Welcome to build WebGAL Terre, the editor of WebGAL platform."
51-
# 安装依赖
52-
yarn install --frozen-lockfile
53-
# 清理
54-
test -d release && rm -rf release
55-
mkdir release
56-
# 进入 Terre 目录
57-
cd packages/terre2
58-
yarn run build
59-
- name: Build pkg ARM64
60-
uses: pguyot/arm-runner-action@v2
61-
with:
62-
base_image: raspios_lite_arm64:latest
63-
bind_mount_repository: true
64-
commands: |
65-
apt-get update
66-
apt-get install -y curl sudo
67-
# Install Node.js v18.x
68-
curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash -
69-
apt-get install -y nodejs
70-
# Enable yarn
71-
corepack prepare [email protected] --activate
72-
corepack enable yarn
73-
cd packages/terre2
74-
yarn run pkg:linux-arm64
75-
- name: Build Stage 2
48+
- name: Build
7649
env:
7750
GH_TOKEN: ${{ secrets.GH_TOKEN }}
78-
run: |
79-
sudo chmod 777 -R .
80-
cd packages/terre2/dist
81-
cp -r WebGAL_Terre ../../../release
82-
rm WebGAL_Terre
83-
cd ../
84-
mkdir Exported_Games
85-
cp -r public assets Exported_Games ../../release
86-
cd ../../
87-
# 进入 Origine 目录
88-
cd packages/origine2
89-
# 低内存,使用下一行限制内存使用
90-
# export NODE_OPTIONS=--max_old_space_size=512000
91-
yarn run build
92-
cp -rf dist/* ../../release/public/
93-
cd ../../
94-
# 进入 Electron 目录
95-
cd packages/WebGAL-electron
96-
yarn install --frozen-lockfile
97-
yarn run build:arm64
98-
mkdir ../../release/assets/templates/WebGAL_Electron_Template
99-
cp -rf build/linux-arm64-unpacked/* ../../release/assets/templates/WebGAL_Electron_Template/
100-
cd ../../
101-
# 克隆 WebGAL Android 模板
102-
cd release/assets/templates/
103-
git clone https://github.com/nini22P/WebGAL-Android.git
104-
mv WebGAL-Android WebGAL_Android_Template
105-
# MainActivity.kt 移动到主文件夹防止误删
106-
mv WebGAL_Android_Template/app/src/main/java/com/openwebgal/demo/MainActivity.kt WebGAL_Android_Template/app/src/main/java/MainActivity.kt
107-
cd ../../../
108-
cd release
109-
# 删除冗余文件
110-
rm -rf Exported_Games/*
111-
rm -rf public/games/*
112-
rm -rf public/games/.gitkeep
113-
rm -rf assets/templates/WebGAL_Template/game/video/*
114-
rm -rf assets/templates/WebGAL_Template/game/video/.gitkeep
115-
rm -rf assets/templates/WebGAL_Android_Template/.github
116-
rm -rf assets/templates/WebGAL_Android_Template/.git
117-
rm -rf assets/templates/WebGAL_Android_Template/.gitattributes
118-
rm -rf assets/templates/WebGAL_Android_Template/app/src/main/assets/webgal/.gitkeep
119-
rm -rf assets/templates/WebGAL_Android_Template/app/src/main/java/com
120-
echo "WebGAL Terre is now ready to be deployed."
51+
run: sh release-linux-arm64.sh
12152
- name: Compress
12253
run: 7z a -tzip release/WebGAL_Terre_Linux_Arm64.zip release/*
12354

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "webgal-terre",
3-
"version": "4.5.11",
3+
"version": "4.5.12",
44
"private": true,
55
"scripts": {
66
"dev": "concurrently \"yarn dev:terre\" \"yarn dev:origine\" \"yarn dev:start-dev-server\"",
@@ -32,5 +32,6 @@
3232
},
3333
"engines": {
3434
"node": "18"
35-
}
35+
},
36+
"packageManager": "[email protected]"
3637
}

packages/WebGAL-electron/main.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
const {app, BrowserWindow, globalShortcut, Menu} = require('electron');
1+
const { app, BrowserWindow, globalShortcut, Menu } = require('electron');
22
const log = require('electron-log');
3+
const path = require('path');
34

45
/**
56
* 关闭默认菜单栏
@@ -23,7 +24,9 @@ app.whenReady().then(() => {
2324
const createWindow = () => {
2425
const win = new BrowserWindow({
2526
width: 1600,
26-
height: 900
27+
height: 900,
28+
icon: path.join(__dirname, '../../icon.ico'),
29+
useContentSize: true,
2730
})
2831

2932
win.loadFile('./public/index.html').then(r => {

packages/origine2/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "webgal-origine-2",
33
"private": true,
4-
"version": "4.5.11",
4+
"version": "4.5.12",
55
"license": "MPL-2.0",
66
"scripts": {
77
"dev": "lingui extract && lingui compile --typescript && vite --host",
@@ -25,7 +25,8 @@
2525
"@codingame/monaco-vscode-localization-service-override": "~4.3.2",
2626
"@codingame/monaco-vscode-rollup-vsix-plugin": "~4.3.2",
2727
"@fluentui/react": "^8.77.3",
28-
"@fluentui/react-components": "^9.44.1",
28+
"@fluentui/react-color-picker-preview": "^0.1.2",
29+
"@fluentui/react-components": "^9.56.8",
2930
"@fluentui/react-icons": "^2.0.224",
3031
"@fluentui/react-icons-mdl2": "^1.3.41",
3132
"@fluentui/react-list-preview": "^0.4.0",

packages/origine2/src/api/Api.ts

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,12 @@ export interface GameInfoDto {
7070
export interface CreateGameDto {
7171
/** The name of the game to be created */
7272
gameName: string;
73+
/** The dir of the game to be created */
74+
gameDir: string;
7375
/** The name of the derivative to be used */
74-
derivative: string;
75-
/** The name of the template to be applied */
76-
templateName: string;
76+
derivative?: string;
77+
/** The dir of the template to be applied */
78+
templateDir?: string;
7779
}
7880

7981
export interface EditFileNameDto {
@@ -133,6 +135,11 @@ export interface RenameDto {
133135
newName: string;
134136
}
135137

138+
export interface IconsDto {
139+
/** The icons of the game */
140+
platforms: string[];
141+
}
142+
136143
export interface TemplateInfoDto {
137144
/** The name of the template */
138145
name: string;
@@ -788,6 +795,22 @@ export class Api<SecurityDataType extends unknown> extends HttpClient<SecurityDa
788795
...params,
789796
}),
790797

798+
/**
799+
* No description
800+
*
801+
* @tags Manage Game
802+
* @name ManageGameControllerGetIcons
803+
* @summary Get Game Icons
804+
* @request GET:/api/manageGame/getIcons/{gameDir}
805+
*/
806+
manageGameControllerGetIcons: (gameDir: string, params: RequestParams = {}) =>
807+
this.request<IconsDto, void>({
808+
path: `/api/manageGame/getIcons/${gameDir}`,
809+
method: 'GET',
810+
format: 'json',
811+
...params,
812+
}),
813+
791814
/**
792815
* No description
793816
*
Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
import { ColorFormats, TinyColor, tinycolor } from '@ctrl/tinycolor';
2+
import {
3+
Button,
4+
Input,
5+
Popover,
6+
PopoverSurface,
7+
PopoverTrigger,
8+
} from '@fluentui/react-components';
9+
import {
10+
ColorPicker,
11+
ColorSlider,
12+
AlphaSlider,
13+
ColorPickerProps,
14+
ColorArea,
15+
} from '@fluentui/react-color-picker-preview';
16+
import { t } from '@lingui/macro';
17+
18+
import styles from './colorPickerPopup.module.scss';
19+
import { useEffect, useMemo, useState } from 'react';
20+
import { ArrowSwapFilled, ArrowSwapRegular, bundleIcon } from '@fluentui/react-icons';
21+
22+
const ArrowSwapIcon = bundleIcon(ArrowSwapFilled, ArrowSwapRegular);
23+
24+
export interface ColorPickerPopupProps {
25+
color: string;
26+
onChange: (color: string) => void;
27+
}
28+
29+
export const formatMap = new Map<ColorFormats, (color: string | TinyColor) => string>([
30+
['hex', (color) => tinycolor(color).a < 1 ? tinycolor(color).toHex8String() : tinycolor(color).toHexString()],
31+
['rgb', (color) => tinycolor(color).toRgbString()],
32+
['hsl', (color) => tinycolor(color).toHslString()],
33+
['hsv', (color) => tinycolor(color).toHsvString()],
34+
]);
35+
36+
export const ColorPickerPopup = ({
37+
color,
38+
onChange,
39+
}: ColorPickerPopupProps) => {
40+
const formats = ['hex', 'rgb', 'hsl', 'hsv'];
41+
const [format, setFormat] = useState(!tinycolor(color).format.startsWith('hex') || formats.includes(tinycolor(color).format) ? tinycolor(color).format : 'hex');
42+
const forMater = useMemo(() => formatMap.get(format) ?? formatMap.get('hex')!, [format]);
43+
const [previewColor, setPreviewColor] = useState(tinycolor(color));
44+
const [inputColor, setInputColor] = useState(tinycolor(color).toString());
45+
46+
useEffect(() => {
47+
if (tinycolor(inputColor).isValid) {
48+
setPreviewColor(tinycolor(inputColor));
49+
}
50+
}, [inputColor]);
51+
52+
useEffect(() => {
53+
if (tinycolor(color).isValid) {
54+
setInputColor(forMater(inputColor));
55+
}
56+
}, [format]);
57+
58+
const handleChangeFormat = () => {
59+
const index = formats.indexOf(format);
60+
const newFormat = formats[(index + 1) % formats.length] as ColorFormats;
61+
setFormat(newFormat);
62+
};
63+
64+
const handleChange: ColorPickerProps['onColorChange'] = (_, data) => {
65+
setInputColor(forMater(tinycolor({ ...data.color, a: data.color.a ?? 1 })));
66+
};
67+
68+
const [popoverOpen, setPopoverOpen] = useState(false);
69+
70+
return (
71+
<Popover
72+
open={popoverOpen}
73+
trapFocus
74+
onOpenChange={(_, data) => setPopoverOpen(data.open)}
75+
>
76+
<PopoverTrigger disableButtonEnhancement>
77+
<Button style={{ paddingLeft: 0, height: '2rem' }}>
78+
<div style={{ backgroundColor: tinycolor(color).toRgbString(), height: '2rem', aspectRatio: '1/1' }} />
79+
<span style={{ marginLeft: '10px', textWrap: 'nowrap' }}>{t`选择颜色`}</span>
80+
</Button>
81+
</PopoverTrigger>
82+
83+
<PopoverSurface>
84+
<ColorPicker color={previewColor.toHsv()} onColorChange={handleChange}>
85+
<ColorArea />
86+
<div className={styles.row}>
87+
<div className={styles.sliders}>
88+
<ColorSlider />
89+
<AlphaSlider />
90+
</div>
91+
<div
92+
className={styles.previewColor}
93+
style={{
94+
backgroundColor: tinycolor(previewColor).toRgbString(),
95+
}}
96+
/>
97+
</div>
98+
<div style={{ marginBottom: '0.5rem', display: 'flex', flexDirection: 'row', justifyContent: 'space-between', gap: '0.5rem' }}>
99+
<Input
100+
style={{ flexGrow: 1 }}
101+
value={inputColor}
102+
contentAfter={<span>{format}</span>}
103+
onChange={(_, data) => setInputColor(data.value)}
104+
/>
105+
<Button icon={<ArrowSwapIcon />} onClick={handleChangeFormat} />
106+
</div>
107+
108+
</ColorPicker>
109+
<div className={styles.actions}>
110+
<Button
111+
onClick={() => {
112+
setPopoverOpen(false);
113+
}}
114+
>
115+
{t`取消`}
116+
</Button>
117+
<Button
118+
appearance='primary'
119+
onClick={() => {
120+
onChange(forMater(previewColor));
121+
setPopoverOpen(false);
122+
}}
123+
>
124+
{t`确定`}
125+
</Button>
126+
</div>
127+
</PopoverSurface>
128+
</Popover>
129+
);
130+
};
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
.container {
2+
display: flex;
3+
flex-direction: row;
4+
justify-content: start;
5+
align-items: center;
6+
gap: 0.5rem;
7+
}
8+
9+
.previewColor {
10+
margin: 10px 0;
11+
width: 50px;
12+
height: 50px;
13+
border-radius: 4px;
14+
border: var(--border-md);
15+
color: #000000;
16+
}
17+
18+
.row {
19+
display: flex;
20+
gap: 10px;
21+
}
22+
23+
.sliders {
24+
display: flex;
25+
flex-direction: column;
26+
justify-content: center;
27+
}
28+
29+
.actions {
30+
display: flex;
31+
flex-direction: row;
32+
justify-content: end;
33+
gap: 0.5rem;
34+
}

0 commit comments

Comments
 (0)