Skip to content

Commit 5a74767

Browse files
author
Hardy--Lee
committed
update adaptive ui
1 parent 753685f commit 5a74767

20 files changed

Lines changed: 147 additions & 66 deletions

packages/webgal/src/Core/controller/storage/saveGame.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,11 @@ export function generateCurrentStageData(index: number, isSavePreviewImage = tru
3636
const canvas: HTMLCanvasElement = document.getElementById('pixiCanvas')! as HTMLCanvasElement;
3737
const canvas2 = document.createElement('canvas');
3838
const context = canvas2.getContext('2d');
39-
canvas2.width = 480;
40-
canvas2.height = 270;
41-
context!.drawImage(canvas, 0, 0, 480, 270);
39+
const previewImageWidth = WebGAL.canvasWidth * 0.2;
40+
const previewImageHeight = WebGAL.canvasHeight * 0.2;
41+
canvas2.width = previewImageWidth;
42+
canvas2.height = previewImageHeight;
43+
context!.drawImage(canvas, 0, 0, previewImageWidth, previewImageHeight);
4244
urlToSave = canvas2.toDataURL('image/webp', 0.5);
4345
canvas2.remove();
4446
}

packages/webgal/src/UI/Backlog/backlog.module.scss

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
@import "../Utils/constants.scss";
2+
13
.Backlog_main {
24
font-family: "思源宋体", serif;
35
position: absolute;
@@ -9,6 +11,7 @@
911
padding: 2em 0 2em 0;
1012
animation: backlog_soft_in 0.7s ease-out forwards;
1113
box-sizing: border-box;
14+
justify-items: center;
1215
}
1316

1417
.Backlog_main_out {
@@ -22,6 +25,7 @@
2225
padding: 2em 0 2em 0;
2326
animation: backlog_soft_out 0.7s ease-out forwards;
2427
box-sizing: border-box;
28+
justify-items: center;
2529
}
2630

2731
// 把z-index置为负数 不然会挡住点击层
@@ -39,6 +43,8 @@
3943
padding: 0 0 0 1em;
4044
display: flex;
4145
height: 10%;
46+
width: 100%;
47+
max-width: $defaultScreenWidth;
4248
}
4349

4450
.backlog_top_icon {
@@ -74,9 +80,10 @@
7480
}
7581

7682
.backlog_content {
77-
position: absolute;
83+
position: relative;
84+
max-width: $defaultScreenHeight;
7885
height: 80%;
79-
padding: 1em 10em 1em 10em;
86+
padding: 1em 5em 1em 5em;
8087
overflow: auto;
8188
display: flex;
8289
flex-flow: column-reverse;

packages/webgal/src/UI/BottomControlPanel/BottomControlPanel.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import { showGlogalDialog, switchControls } from '@/UI/GlobalDialog/GlobalDialog
3131
import { useEffect } from 'react';
3232
import { getSavesFromStorage } from '@/Core/controller/storage/savesController';
3333
import { easyCompile } from '@/UI/Menu/SaveAndLoad/Save/Save';
34+
import { HorizontalScroll } from '@/UI/Utils/HorizontalScroll';
3435

3536
export const BottomControlPanel = () => {
3637
const t = useTrans('gaming.');
@@ -66,7 +67,7 @@ export const BottomControlPanel = () => {
6667
fastSlPreview = (
6768
<div className={styles.slPreviewMain}>
6869
<div className={styles.imgContainer}>
69-
<img style={{ height: '100%' }} alt="q-save-preview image" src={data.previewImage} />
70+
<img className={styles.previewImg} alt="q-save-preview image" src={data.previewImage} />
7071
</div>
7172
<div className={styles.textContainer}>
7273
<div>{easyCompile(data.nowStageState.showName)}</div>
@@ -80,7 +81,8 @@ export const BottomControlPanel = () => {
8081
// <div className={styles.ToCenter}>
8182
<>
8283
{GUIStore.showTextBox && stageState.enableFilm === '' && (
83-
<div className={styles.main} style={{ visibility: GUIStore.controlsVisibility ? 'visible' : 'hidden' }}>
84+
<HorizontalScroll className={styles.main} style={{ visibility: GUIStore.controlsVisibility ? 'visible' : 'hidden' }}>
85+
<div style={{flexGrow: 1}}/>
8486
{GUIStore.showTextBox && (
8587
<span
8688
className={styles.singleButton}
@@ -313,7 +315,7 @@ export const BottomControlPanel = () => {
313315
<Unlock className={styles.button} theme="outline" size={size} fill="#f5f5f7" strokeWidth={strokeWidth} />
314316
)}
315317
</span>
316-
</div>
318+
</HorizontalScroll>
317319
)}
318320
</>
319321
// </div>

packages/webgal/src/UI/BottomControlPanel/bottomControlPanel.module.scss

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,17 @@
1616
z-index: 9;
1717
display: flex;
1818
//background-image: linear-gradient(rgba(245, 247, 250, 0.7) 0%, rgba(195, 207, 226, 0.7) 100%);
19-
flex-flow: row;
20-
justify-content: center;
21-
align-items: center;
2219
//width: 100%;
23-
height: 70px;
20+
left: 20px;
2421
right: 20px;
25-
border-radius: 35px;
2622
//backdrop-filter: blur(5px);
2723
padding: 0.15em 1.75em 0.15em 1.75em;
2824
//background: linear-gradient(rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 0.25) 100%);
2925
//border-radius: 10px;
3026
font-size: 80%;
27+
align-items: end;
28+
overflow-x: auto;
29+
scrollbar-width: none;
3130
}
3231

3332
.button {
@@ -49,11 +48,12 @@
4948
height: 100%;
5049
display: inline-block;
5150
font-size: 150%;
52-
padding: 0.25em 0.3em 0 0.15em;
51+
padding: 0.2em 0.3em 0.0em 0.3em;
5352
transition: background-color 0.5s;
5453
background: rgba(255, 255, 255, 0.3);
5554
border-radius: 4px;
5655
margin: 0 0.1em 0 0.1em;
56+
flex-shrink: 0;
5757
}
5858

5959
.singleButton {
@@ -62,16 +62,19 @@
6262
display: inline-block;
6363
color: white;
6464
font-size: 150%;
65-
padding: 0.3em 0.3em 0 0.15em;
65+
padding: 0.2em 0.3em 0.0em 0.3em;
6666
transition: background-color 0.5s;
6767
cursor: pointer;
6868
border-radius: 4px;
6969
margin: 0 0.1em 0 0.1em;
7070
position: relative;
71+
flex-shrink: 0;
7172
}
7273

7374
.singleButton:hover {
7475
background-color: rgba(255, 255, 255, 0.3);
76+
// 此处是为了让快速读存档弹窗不被裁剪
77+
margin-top: 300px;
7578
}
7679

7780
.fastSlPreview {
@@ -115,11 +118,21 @@
115118

116119
.imgContainer {
117120
display: flex;
118-
overflow: hidden;
121+
// overflow: hidden;
119122
border-radius: 5px;
120123
//outline: 4px solid #005caf;
121124
flex-shrink: 0;
122125
height: 100%;
126+
aspect-ratio: 16/9;
127+
}
128+
129+
.previewImg {
130+
width: 100%;
131+
height: 100%;
132+
// aspect-ratio: 4/3;
133+
// height: 100%;
134+
object-fit: cover;
135+
// height: 200%;
123136
}
124137

125138
.textContainer {

packages/webgal/src/UI/Extra/ExtraBgm.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ export function ExtraBgm() {
1919
let foundCurrentBgmName = initName;
2020
let foundCurrentBgmIndex = -1;
2121
const iconSize = 39;
22-
const bgmPlayerHeight = isShowBgmList.value ? '80%' : '10%';
2322
const bgmListLen = extraState.bgm.length;
2423
extraState.bgm.forEach((e, i) => {
2524
if (e.url === currentBgmSrc) {
@@ -63,7 +62,7 @@ export function ExtraBgm() {
6362
);
6463
});
6564
return (
66-
<div className={styles.bgmContainer} style={{ maxHeight: bgmPlayerHeight }}>
65+
<div className={styles.bgmContainer}>
6766
<div className={styles.bgmPlayerMain}>
6867
<div
6968
onClick={() => {

packages/webgal/src/UI/Extra/ExtraCg.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { useValue } from '@/hooks/useValue';
66
import './extraCG_animation_List.scss';
77
import { ExtraCgElement } from '@/UI/Extra/ExtraCgElement';
88
import useSoundEffect from '@/hooks/useSoundEffect';
9+
import HorizontalScroll from '@/UI//Utils/HorizontalScroll';
910

1011
export function ExtraCg() {
1112
const cgPerPage = 8;
@@ -63,7 +64,7 @@ export function ExtraCg() {
6364
return (
6465
<div className={styles.cgMain}>
6566
<div className={styles.cgShowDiv}>
66-
<div className={styles.cgShowDivWarpper}>{showNav}</div>
67+
<HorizontalScroll className={styles.cgShowDivWarpper}>{showNav}</HorizontalScroll>
6768
</div>
6869
<div className={styles.cgContainer}>{showCgList}</div>
6970
</div>

packages/webgal/src/UI/Extra/ExtraCgElement.tsx

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,9 @@ export function ExtraCgElement(props: IProps) {
4545
);
4646
} else if (isImage) {
4747
return (
48-
<div
49-
style={{
50-
backgroundImage: `url('${props.resourceUrl}')`,
51-
backgroundSize: 'cover',
52-
backgroundPosition: 'center',
53-
width: '100%',
54-
height: '100%',
55-
}}
48+
<img
49+
className={styles.cgImage}
50+
src = {props.resourceUrl}
5651
/>
5752
);
5853
} else {

packages/webgal/src/UI/Extra/extra.module.scss

Lines changed: 33 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
@import "../Utils/constants.scss";
2+
13
.extra {
24
width: 100%;
35
height: 100%;
@@ -8,12 +10,14 @@
810
background-image: linear-gradient(135deg, #93a5cf 0%, #e4efe9 100%);;
911
padding: 2em 2em 2em 2em;
1012
box-sizing: border-box;
13+
justify-items: center;
1114
}
1215

1316
.extra_top {
1417
padding: 0 0 0 0;
1518
display: flex;
16-
height: 10%;
19+
width: 100%;
20+
max-width: $defaultScreenWidth;
1721
}
1822

1923
.extra_top_icon {
@@ -51,10 +55,11 @@
5155

5256
.mainContainer {
5357
box-sizing: border-box;
54-
padding: 0 2em 0 2em;
5558
display: flex;
56-
height: 92%;
59+
width: 100%;
5760
flex-flow: column;
61+
max-width: $defaultScreenWidth;
62+
align-items: center;
5863
}
5964

6065
.bgmContainer {
@@ -63,8 +68,11 @@
6368
bottom: 30px;
6469
position: absolute;
6570
overflow: auto;
66-
//width: 100%;
71+
width: 93%;
6772
//height: 70%;
73+
max-width: $defaultScreenWidth;
74+
max-height: 70%;
75+
justify-self: center;
6876
box-sizing: border-box;
6977
display: flex;
7078
flex-flow: column-reverse;
@@ -89,7 +97,7 @@
8997
align-items: flex-start;
9098
margin: 0 0 15px 0;
9199
flex-wrap: wrap;
92-
overflow: auto;
100+
overflow-y: auto;
93101
}
94102

95103
.bgmPlayerMain {
@@ -166,31 +174,39 @@
166174
width: 100%;
167175
display: flex;
168176
flex-wrap: wrap;
169-
justify-content: flex-start;
177+
justify-content: center;
170178
align-items: flex-start;
171179
align-content: flex-start;
172-
height: 90%;
180+
// height: 90%;
173181
box-sizing: border-box;
174-
padding: 4em 0 0 2em;
182+
padding: 4em 2em 4em 2em;
183+
height: 1000px;
184+
overflow-y: auto;
175185
}
176186

177187
.cgElement {
178-
width: 22.5%;
179-
height: 37.5%;
188+
height: 300px;
189+
width: auto;
180190
background-color: rgba(255, 255, 255, 0.75);
181191
box-shadow: 0 0 15px 5px rgba(0, 0, 0, 0.35);
182192
box-sizing: border-box;
183193
padding: 0.75em 0.75em 0.75em 0.75em;
184194
opacity: 0;
185-
margin: 1em 1em 1em 1em;
195+
margin: 1.5em 1em 1.5em 1em;
186196
animation-delay: 100ms;
187197
z-index: 1;
188-
position: relative;
198+
position: initial;
189199
cursor: pointer;
190200
}
191201

202+
.cgImage {
203+
width: 100%;
204+
height: 100%;
205+
object-fit: contain;
206+
}
207+
192208
.cgShowDiv {
193-
height: 8%;
209+
// height: 8%;
194210
width: 100%;
195211
display: flex;
196212
flex-flow: row;
@@ -201,11 +217,13 @@
201217
.cgShowDivWarpper {
202218
display: flex;
203219
flex-flow: row;
204-
justify-content: center;
220+
// justify-content: center;
205221
align-items: flex-end;
206222
//background: rgba(255, 255, 255, 0.35);
207223
border-radius: 7px;
208224
padding: 12px 15px;
225+
overflow-x: auto;
226+
// scrollbar-width: none;
209227
}
210228

211229
.cgNav {
@@ -247,16 +265,14 @@
247265
left: 0;
248266
width: 100%;
249267
height: 100%;
250-
background: rgba(0, 0, 0, 0.1);
268+
background: rgba(0, 0, 0, 0.5);
251269
display: flex;
252270
justify-content: center;
253271
align-items: center;
254272
}
255273

256274
.showFullCgMain {
257275
cursor: pointer;
258-
width: 80%;
259-
height: 80%;
260276
box-sizing: border-box;
261277
padding: 2em 2em 2em 2em;
262278
background: rgba(255, 255, 255, 0.95);

packages/webgal/src/UI/GlobalDialog/globalDialog.module.scss

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
}
3333

3434
.glabalDialog_container {
35-
height: 20%;
3635
width: 100%;
3736
border-top: 4px solid;
3837
border-bottom: 4px solid;

packages/webgal/src/UI/Menu/MenuPanel/MenuPanel.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { backToTitle } from '@/Core/controller/gamePlay/backToTitle';
99
import useTrans from '@/hooks/useTrans';
1010
import useSoundEffect from '@/hooks/useSoundEffect';
1111
import { showGlogalDialog } from '@/UI/GlobalDialog/GlobalDialog';
12+
import HorizontalScroll from '@/UI/Utils/HorizontalScroll';
1213

1314
/**
1415
* Menu页的底栏
@@ -40,7 +41,7 @@ export const MenuPanel = () => {
4041
GUIState.currentMenuTag === MenuPanelTag.Option ? `rgba(81, 110, 65, 0.9)` : `rgba(123,144,169,1)`;
4142

4243
return (
43-
<div className={styles.MenuPanel_main}>
44+
<HorizontalScroll className={styles.MenuPanel_main}>
4445
<MenuPanelButton
4546
iconName="save"
4647
buttonOnClassName={SaveTagOn}
@@ -111,6 +112,6 @@ export const MenuPanel = () => {
111112
tagName={t('exit.title')}
112113
key="exitIcon"
113114
/>
114-
</div>
115+
</HorizontalScroll>
115116
);
116117
};

0 commit comments

Comments
 (0)