ChenyuRabbitLove commited on
Commit
f38bc69
1 Parent(s): 9bb3bc6

bugfix: fix minor bugs

Browse files
Files changed (1) hide show
  1. app.py +199 -198
app.py CHANGED
@@ -79,218 +79,219 @@ with gr.Blocks(theme=seafoam, css=get_content("css/style.css")) as demo:
79
  # completion_reward = gr.State(init_reward)
80
  player_activity_tracker = gr.State(create_new_player_activity)
81
 
82
- with gr.Row():
83
- with gr.Column(
84
- scale=1,
85
- elem_classes="gallery_container",
86
- ):
87
- pet_description = gr.Markdown("# 夥伴", elem_id="pet_avatar_description")
88
- pet_gallery = gr.Gallery(
89
- [],
90
- label="夥伴",
91
- preview=False,
92
- elem_id="pet_gallery",
93
- columns=30,
94
- height=200,
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
95
  )
 
96
 
97
- badge_description = gr.Markdown("# 徽章", elem_id="badge_avatar_description")
98
- badge_gallery = gr.Gallery(
99
- [],
100
- label="徽章",
101
- preview=False,
102
- elem_id="badge_gallery",
103
- columns=30,
104
- height=200,
105
  )
 
 
106
 
107
- with gr.Column(scale=1, elem_id="player_avatar_container"):
108
- avatar = gr.Image(
109
- "avatar/blank_avatar.png",
110
- elem_id="player_avatar",
111
  )
112
- avatar_description = gr.Markdown(
113
- "# 光束守護者", elem_id="player_avatar_description"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
114
  )
115
 
116
- with gr.Column(scale=1):
117
- adventure_description = gr.Markdown(
118
- "# 冒險階段", elem_id="adventure_description"
 
 
 
 
119
  )
120
- adventure = gr.Slider(
121
- value=0,
122
- show_label=False,
 
123
  interactive=False,
124
- elem_id="adventure_slider",
125
- info="",
126
  )
127
- achievements_description = gr.Markdown(
128
- "# 達成成就", elem_id="achievements_description"
 
 
 
 
129
  )
130
- achievements = gr.HighlightedText(
131
- value=[],
132
- elem_classes="achievements",
133
- color_map={
134
- "完成": "green",
135
- "未完成": "red",
136
- },
137
  )
138
 
139
- with gr.Row():
140
- html = (
141
- "<div style='max-width:100%; max-height:360px; overflow:auto'>"
142
- + get_content("htmls/adventure_blank.html")
143
- )
144
- adventure_log = gr.HTML(html, label="Adventure Log", elem_id="adventure_log")
145
 
146
- # handling player info
147
- with gr.Row():
148
- player_backend_id = gr.Textbox("", elem_id="player_backend_id", visible=False)
149
- player_info_query_btn = gr.Button(
150
- "Query", elem_id="trigger_button", visible=False
151
- )
152
- pull_newest_player_data = gr.Textbox("", visible=False)
153
- update_status = gr.Textbox("", visible=False)
154
-
155
- # with gr.Tab("完賽獎勵"):
156
- # with gr.Row():
157
- # start_make_reward = gr.Button(
158
- # "開始製作完賽獎勵!", visible=True, elem_id="start_make_reward"
159
- # )
160
-
161
- # with gr.Row():
162
- # not_participate = gr.Markdown(
163
- # "# 同學並未參與 2023 的星空探險隊唷!", visible=False, elem_id="not_participate"
164
- # )
165
-
166
- # with gr.Row():
167
- # not_start = gr.Markdown(
168
- # "# 完賽獎勵還���有開放申請,但是就快了,請敬請期待!", visible=False, elem_id="not_start"
169
- # )
170
-
171
- # with gr.Row():
172
- # already_issued = gr.Image(visible=False)
173
-
174
- # with gr.Row():
175
- # player_name_title = gr.Markdown(
176
- # "# 選擇玩家暱稱", visible=False, elem_id="player_name_title"
177
- # )
178
-
179
- # with gr.Row():
180
- # player_name = gr.Textbox(
181
- # label="玩家暱稱",
182
- # info="請輸入想要用在完賽獎勵上的玩家暱稱,上限為 10 字,獎勵發送後無法更改也無法補發,還請同學們謹慎填寫。",
183
- # interactive=True,
184
- # elem_id="player_name",
185
- # visible=False,
186
- # )
187
-
188
- # with gr.Row():
189
- # confirm_player_name = gr.Button(
190
- # "確認暱稱", elem_id="confirm_player_name", visible=False
191
- # )
192
- # cancel_player_name = gr.Button(
193
- # "取消", elem_id="cancel_player_name", visible=False
194
- # )
195
-
196
- # with gr.Row():
197
- # player_name_next_step = gr.Button(
198
- # "下一步", visible=False, elem_id="player_name_next_step"
199
- # )
200
-
201
- # with gr.Row():
202
- # story_title = gr.Markdown("# 選擇冒險故事", visible=False, elem_id="story_title")
203
-
204
- # with gr.Row():
205
- # story_description = gr.Markdown(
206
- # "有五位星際夥伴來為你撰寫專屬於你的冒險故事,每位星際夥伴都會得到同學冒險週記的內容,並寫成一段故事,請同學選擇自己最喜歡的一段故事,這段故事將會被用來印在獎狀上<br><br>小叮嚀:請同學選擇喜歡的故事內容,而不是星際夥伴唷!星際夥伴可是不會和同學們一起冒險的!最後,撰寫故事的過程大概需要幾分鐘的時間,請同學耐心等待",
207
- # visible=False,
208
- # elem_id="story_description",
209
- # )
210
-
211
- # with gr.Row():
212
- # openai_description = gr.Markdown(
213
- # "# 露米娜", elem_id="openai_description", visible=False
214
- # )
215
- # aws_description = gr.Markdown(
216
- # "# 索拉拉", elem_id="aws_description", visible=False
217
- # )
218
- # google_description = gr.Markdown(
219
- # "# 薇丹特", elem_id="google_description", visible=False
220
- # )
221
- # mtk_description = gr.Markdown(
222
- # "# 蔚藍", elem_id="mtk_description", visible=False
223
- # )
224
-
225
- # with gr.Row():
226
- # openai_img = gr.Image(
227
- # "medias/lumina.png",
228
- # visible=False,
229
- # elem_id="openai_img",
230
- # interactive=False,
231
- # show_download_button=False,
232
- # )
233
- # aws_img = gr.Image(
234
- # "medias/solara.png",
235
- # visible=False,
236
- # elem_id="aws_img",
237
- # interactive=False,
238
- # show_download_button=False,
239
- # )
240
- # google_img = gr.Image(
241
- # "medias/verdant.png",
242
- # visible=False,
243
- # elem_id="google_img",
244
- # interactive=False,
245
- # show_download_button=False,
246
- # )
247
- # mtk_img = gr.Image(
248
- # "medias/azure.png",
249
- # visible=False,
250
- # elem_id="mtk_img",
251
- # interactive=False,
252
- # show_download_button=False,
253
- # )
254
-
255
- # with gr.Row():
256
- # start_generate_story = gr.Button(
257
- # "開始寫作故事", visible=False, elem_id="start_generate_story"
258
- # )
259
-
260
- # with gr.Row():
261
- # bot1 = gr.Chatbot(visible=False)
262
- # bot2 = gr.Chatbot(visible=False)
263
- # bot3 = gr.Chatbot(visible=False)
264
- # bot4 = gr.Chatbot(visible=False)
265
-
266
- # with gr.Row():
267
- # select_story = gr.Radio(
268
- # ["露米娜", "索拉拉", "薇丹特", "蔚藍"],
269
- # interactive=True,
270
- # label="選擇故事",
271
- # visible=False,
272
- # elem_id="select_story",
273
- # )
274
-
275
- # with gr.Row():
276
- # confirm_story = gr.Button("確認故事", visible=False, elem_id="confirm_story")
277
- # cancel_story = gr.Button("取消", visible=False, elem_id="cancel_story")
278
-
279
- # with gr.Row():
280
- # start_generate_certificate = gr.Button(
281
- # "開始製作完賽獎勵!", visible=False, elem_id="start_generate_certificate"
282
- # )
283
- # processing = gr.Button(
284
- # "製作中...",
285
- # visible=False,
286
- # elem_id="processing",
287
- # size="lg",
288
- # interactive=False,
289
- # )
290
- # complete = gr.Markdown("# 完成!", visible=False, elem_id="complete")
291
-
292
- # with gr.Row():
293
- # reward_result = gr.Image(visible=False)
294
 
295
  # actions when player login
296
  # define args
 
79
  # completion_reward = gr.State(init_reward)
80
  player_activity_tracker = gr.State(create_new_player_activity)
81
 
82
+ with gr.Tab("個人化戰報"):
83
+ with gr.Row():
84
+ with gr.Column(
85
+ scale=1,
86
+ elem_classes="gallery_container",
87
+ ):
88
+ pet_description = gr.Markdown("# 夥伴", elem_id="pet_avatar_description")
89
+ pet_gallery = gr.Gallery(
90
+ [],
91
+ label="夥伴",
92
+ preview=False,
93
+ elem_id="pet_gallery",
94
+ columns=30,
95
+ height=200,
96
+ )
97
+
98
+ badge_description = gr.Markdown("# 徽章", elem_id="badge_avatar_description")
99
+ badge_gallery = gr.Gallery(
100
+ [],
101
+ label="徽章",
102
+ preview=False,
103
+ elem_id="badge_gallery",
104
+ columns=30,
105
+ height=200,
106
+ )
107
+
108
+ with gr.Column(scale=1, elem_id="player_avatar_container"):
109
+ avatar = gr.Image(
110
+ "avatar/blank_avatar.png",
111
+ elem_id="player_avatar",
112
+ )
113
+ avatar_description = gr.Markdown(
114
+ "# 光束守護者", elem_id="player_avatar_description"
115
+ )
116
+
117
+ with gr.Column(scale=1):
118
+ adventure_description = gr.Markdown(
119
+ "# 冒險階段", elem_id="adventure_description"
120
+ )
121
+ adventure = gr.Slider(
122
+ value=0,
123
+ show_label=False,
124
+ interactive=False,
125
+ elem_id="adventure_slider",
126
+ info="",
127
+ )
128
+ achievements_description = gr.Markdown(
129
+ "# 達成成就", elem_id="achievements_description"
130
+ )
131
+ achievements = gr.HighlightedText(
132
+ value=[],
133
+ elem_classes="achievements",
134
+ color_map={
135
+ "完成": "green",
136
+ "未完成": "red",
137
+ },
138
+ )
139
+
140
+ with gr.Row():
141
+ html = (
142
+ "<div style='max-width:100%; max-height:360px; overflow:auto'>"
143
+ + get_content("htmls/adventure_blank.html")
144
  )
145
+ adventure_log = gr.HTML(html, label="Adventure Log", elem_id="adventure_log")
146
 
147
+ # handling player info
148
+ with gr.Row():
149
+ player_backend_id = gr.Textbox("", elem_id="player_backend_id", visible=False)
150
+ player_info_query_btn = gr.Button(
151
+ "Query", elem_id="trigger_button", visible=False
 
 
 
152
  )
153
+ pull_newest_player_data = gr.Textbox("", visible=False)
154
+ update_status = gr.Textbox("", visible=False)
155
 
156
+ with gr.Tab("完賽獎勵"):
157
+ with gr.Row():
158
+ start_make_reward = gr.Button(
159
+ "開始製作完賽獎勵!", visible=True, elem_id="start_make_reward"
160
  )
161
+
162
+ with gr.Row():
163
+ not_participate = gr.Markdown(
164
+ "# 同學並未參與 2023 的星空探險隊唷!", visible=False, elem_id="not_participate"
165
+ )
166
+
167
+ with gr.Row():
168
+ not_start = gr.Markdown(
169
+ "# 完賽獎勵還沒有開放申請,但是就快了,請敬請期待!", visible=False, elem_id="not_start"
170
+ )
171
+
172
+ with gr.Row():
173
+ already_issued = gr.Image(visible=False)
174
+
175
+ with gr.Row():
176
+ player_name_title = gr.Markdown(
177
+ "# 選擇玩家暱稱", visible=False, elem_id="player_name_title"
178
+ )
179
+
180
+ with gr.Row():
181
+ player_name = gr.Textbox(
182
+ label="玩家暱稱",
183
+ info="請輸入想要用在完賽獎勵上的玩家暱稱,上限為 10 字,獎勵發送後無法更改也無法補發,還請同學們謹慎填寫。",
184
+ interactive=True,
185
+ elem_id="player_name",
186
+ visible=False,
187
+ )
188
+
189
+ with gr.Row():
190
+ confirm_player_name = gr.Button(
191
+ "確認暱稱", elem_id="confirm_player_name", visible=False
192
+ )
193
+ cancel_player_name = gr.Button(
194
+ "取消", elem_id="cancel_player_name", visible=False
195
+ )
196
+
197
+ with gr.Row():
198
+ player_name_next_step = gr.Button(
199
+ "下一步", visible=False, elem_id="player_name_next_step"
200
+ )
201
+
202
+ with gr.Row():
203
+ story_title = gr.Markdown("# 選擇冒險故事", visible=False, elem_id="story_title")
204
+
205
+ with gr.Row():
206
+ story_description = gr.Markdown(
207
+ "有五位星際夥伴來為你撰寫專屬於你的冒險故事,每位星際夥伴都會得到同學冒險週記的內容,並寫成一段故事,請同學選擇自己最喜歡的一段故事,這段故事將會被用來印在獎狀上<br><br>小叮嚀:請同學選擇喜歡的故事內容,而不是星際夥伴唷!星際夥伴可是不會和同學們一起冒險的!最後,撰寫故事的過程大概需要幾分鐘的時間,請同學耐心等待",
208
+ visible=False,
209
+ elem_id="story_description",
210
+ )
211
+
212
+ with gr.Row():
213
+ openai_description = gr.Markdown(
214
+ "# 露米娜", elem_id="openai_description", visible=False
215
+ )
216
+ aws_description = gr.Markdown(
217
+ "# 索拉拉", elem_id="aws_description", visible=False
218
+ )
219
+ google_description = gr.Markdown(
220
+ "# 薇丹特", elem_id="google_description", visible=False
221
+ )
222
+ mtk_description = gr.Markdown(
223
+ "# 蔚藍", elem_id="mtk_description", visible=False
224
  )
225
 
226
+ with gr.Row():
227
+ openai_img = gr.Image(
228
+ "medias/lumina.png",
229
+ visible=False,
230
+ elem_id="openai_img",
231
+ interactive=False,
232
+ show_download_button=False,
233
  )
234
+ aws_img = gr.Image(
235
+ "medias/solara.png",
236
+ visible=False,
237
+ elem_id="aws_img",
238
  interactive=False,
239
+ show_download_button=False,
 
240
  )
241
+ google_img = gr.Image(
242
+ "medias/verdant.png",
243
+ visible=False,
244
+ elem_id="google_img",
245
+ interactive=False,
246
+ show_download_button=False,
247
  )
248
+ mtk_img = gr.Image(
249
+ "medias/azure.png",
250
+ visible=False,
251
+ elem_id="mtk_img",
252
+ interactive=False,
253
+ show_download_button=False,
 
254
  )
255
 
256
+ with gr.Row():
257
+ start_generate_story = gr.Button(
258
+ "開始寫作故事", visible=False, elem_id="start_generate_story"
259
+ )
 
 
260
 
261
+ with gr.Row():
262
+ bot1 = gr.Chatbot(visible=False)
263
+ bot2 = gr.Chatbot(visible=False)
264
+ bot3 = gr.Chatbot(visible=False)
265
+ bot4 = gr.Chatbot(visible=False)
266
+
267
+ with gr.Row():
268
+ select_story = gr.Radio(
269
+ ["露米娜", "索拉拉", "薇丹特", "蔚藍"],
270
+ interactive=True,
271
+ label="選擇故事",
272
+ visible=False,
273
+ elem_id="select_story",
274
+ )
275
+
276
+ with gr.Row():
277
+ confirm_story = gr.Button("確認故事", visible=False, elem_id="confirm_story")
278
+ cancel_story = gr.Button("取消", visible=False, elem_id="cancel_story")
279
+
280
+ with gr.Row():
281
+ start_generate_certificate = gr.Button(
282
+ "開始製作完賽獎勵!", visible=False, elem_id="start_generate_certificate"
283
+ )
284
+ processing = gr.Button(
285
+ "製作中...",
286
+ visible=False,
287
+ elem_id="processing",
288
+ size="lg",
289
+ interactive=False,
290
+ )
291
+ complete = gr.Markdown("# 完成!", visible=False, elem_id="complete")
292
+
293
+ with gr.Row():
294
+ reward_result = gr.Image(visible=False)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
295
 
296
  # actions when player login
297
  # define args