Surn commited on
Commit
63cbfa3
·
1 Parent(s): 4dab390

Bug Fixes 0.2.14

Browse files

- bug fix on final score popup
- score panel alignment centered
- change incorrect guess history UI

Files changed (3) hide show
  1. README.md +5 -0
  2. battlewords/__init__.py +1 -1
  3. battlewords/ui.py +34 -18
README.md CHANGED
@@ -106,6 +106,11 @@ docker run -p 8501:8501 battlewords
106
 
107
  ## Changelog
108
 
 
 
 
 
 
109
  -0.2.13
110
  - upgrade background ocean view
111
  - apply volume control to sound effects
 
106
 
107
  ## Changelog
108
 
109
+ -0.2.14
110
+ - bug fix on final score popup
111
+ - score panel alignment centered
112
+ - change incorrect guess history UI
113
+
114
  -0.2.13
115
  - upgrade background ocean view
116
  - apply volume control to sound effects
battlewords/__init__.py CHANGED
@@ -1,2 +1,2 @@
1
- __version__ = "0.2.13"
2
  __all__ = ["models", "generator", "logic", "ui"]
 
1
+ __version__ = "0.2.14"
2
  __all__ = ["models", "generator", "logic", "ui"]
battlewords/ui.py CHANGED
@@ -240,7 +240,7 @@ def inject_styles() -> None:
240
  min-width: 1.25em;
241
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
242
  background: #1d64c8; /* Base cell color */
243
- color: #ffffff; /* Base text color for contrast */
244
  }
245
  /* Found letter cells */
246
  .bw-cell.letter { background: #d7faff; color: #050057; }
@@ -298,7 +298,8 @@ def inject_styles() -> None:
298
  .metal-border { position: relative; padding: 20px; background: #333; color: white; border: 4px solid; border-image: linear-gradient(45deg, #a1a1a1, #ffffff, #a1a1a1, #666666) 1; border-radius: 8px; }
299
  .shiny-border { position: relative; padding: 12px; background: #333; color: white; border-radius: 1.25rem; overflow: hidden; }
300
  .shiny-border::before { content: ''; position: absolute; top: 0; left: -100%; width: 100%; height: 100%; background: linear-gradient(90deg, transparent, rgba(255,255,255,0.4), transparent); transition: left 0.5s; }
301
- .bw-score-panel-container { height: 100%; overflow: hidden; }
 
302
  .shiny-border:hover::before { left: 100%; }
303
 
304
  .bw-radio-group { display:flex; align-items:flex-start; gap: 10px; flex-flow: row; }
@@ -1031,12 +1032,23 @@ def _render_guess_form(state: GameState):
1031
  <style>
1032
  .bw-incorrect-guesses {
1033
  font-size: 0.7rem;
1034
- color: #fff;
1035
  margin-top: -10px;
1036
- # padding: 2px 4px;
1037
- # background: rgba(255, 255, 255, 0.05);
1038
- # border-radius: 10px;
1039
- # font-style: italic;
 
 
 
 
 
 
 
 
 
 
 
1040
  }
1041
  </style>
1042
  """,
@@ -1051,17 +1063,18 @@ def _render_guess_form(state: GameState):
1051
  value="",
1052
  max_chars=10,
1053
  width=200,
1054
- key="guess_input"
 
1055
  )
1056
  with col2:
1057
  submitted = st.form_submit_button("OK", disabled=not state.can_guess, width=100, key="guess_submit")
1058
 
1059
  # Show compact list below input if setting is enabled
1060
- if st.session_state.get("show_incorrect_guesses", False) and recent_incorrect:
1061
- st.markdown(
1062
- f'<div class="bw-incorrect-guesses" title="{tooltip_text}">Recent incorrect guesses:</div>',
1063
- unsafe_allow_html=True,
1064
- )
1065
 
1066
  if submitted:
1067
  correct, _ = guess_word(state, guess_text)
@@ -1070,12 +1083,12 @@ def _render_guess_form(state: GameState):
1070
  if correct:
1071
  st.session_state.radar_gif_path = None
1072
  st.session_state.radar_gif_signature = None
1073
- play_sound_effect("correct_guess", volume=(st.session_state.get("effects_volume", 50) / 100))
1074
  else:
1075
  # Update incorrect guesses list - keep only last 10
1076
  st.session_state.incorrect_guesses.append(guess_text)
1077
  st.session_state.incorrect_guesses = st.session_state.incorrect_guesses[-10:]
1078
- play_sound_effect("incorrect_guess", volume=(st.session_state.get("effects_volume", 50) / 100))
1079
  st.rerun()
1080
 
1081
 
@@ -1146,6 +1159,8 @@ def _render_score_panel(state: GameState):
1146
  .bold-text {{ font-weight: 700; }}
1147
  .blue-background {{ background:#1d64c8; opacity:0.9; color:#fff; }}
1148
  .shiny-border {{ position: relative; padding: 12px; background: #333; color: white; border-radius: 1.25rem; overflow: hidden; }}
 
 
1149
  table {{ width: 100%; margin: 0 auto; border-collapse: separate; border-spacing: 0; }}
1150
  th, td {{ padding: 6px 8px; }}
1151
  </style>
@@ -1211,7 +1226,7 @@ def _game_over_content(state: GameState) -> None:
1211
  if os.path.exists(congrats_music_path):
1212
  src_url = _load_audio_data_url(congrats_music_path)
1213
  # Play once (no loop) at configured volume
1214
- _mount_background_audio(enabled=True, src_url=src_url, volume=(st.session_state.get("music_volume", 100)) / 100, loop=False)
1215
  else:
1216
  _mount_background_audio(False, None, 0.0)
1217
 
@@ -1245,7 +1260,7 @@ def _game_over_content(state: GameState) -> None:
1245
  "<th scope=\"col\">Extra</th>"
1246
  "</tr></thead>"
1247
  f"<tbody>{''.join(word_rows)}"
1248
- f"<tr><td colspan=\"3\"><h5 class=\"m-2\">Total: {state.score} <span style='font-size:1rem; color:#1d64c8;'>&nbsp;⏱ {timer_str}</span></h5></td></tr>"
1249
  "</tbody>"
1250
  "</table>"
1251
  )
@@ -1269,6 +1284,7 @@ def _game_over_content(state: GameState) -> None:
1269
  min-width: unset !important;
1270
  margin: 25px auto 0;
1271
  }
 
1272
  .st-key-new_game_btn_dialog button, .st-key-close_game_over button {
1273
  height: 50px !important;
1274
  }
@@ -1330,7 +1346,7 @@ def _render_game_over(state: GameState):
1330
  congrats_music_path = os.path.join(music_dir, "congratulations.mp3")
1331
  if os.path.exists(congrats_music_path):
1332
  src_url = _load_audio_data_url(congrats_music_path)
1333
- _mount_background_audio(enabled=True, src_url=src_url, volume=(st.session_state.get("music_volume", 100)) / 100, loop=False)
1334
  else:
1335
  _mount_background_audio(False, None, 0.0)
1336
  _game_over_dialog(state)
 
240
  min-width: 1.25em;
241
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
242
  background: #1d64c8; /* Base cell color */
243
+ color: #FFFFFF; /* Base text color for contrast */
244
  }
245
  /* Found letter cells */
246
  .bw-cell.letter { background: #d7faff; color: #050057; }
 
298
  .metal-border { position: relative; padding: 20px; background: #333; color: white; border: 4px solid; border-image: linear-gradient(45deg, #a1a1a1, #ffffff, #a1a1a1, #666666) 1; border-radius: 8px; }
299
  .shiny-border { position: relative; padding: 12px; background: #333; color: white; border-radius: 1.25rem; overflow: hidden; }
300
  .shiny-border::before { content: ''; position: absolute; top: 0; left: -100%; width: 100%; height: 100%; background: linear-gradient(90deg, transparent, rgba(255,255,255,0.4), transparent); transition: left 0.5s; }
301
+ .bw-score-panel-container { height: 100%; overflow: hidden; text-align:center;}
302
+ .bw-score-panel-container table tbody tr h3 {display: flex;flex-direction: row;justify-content: space-evenly;flex-wrap: wrap;}
303
  .shiny-border:hover::before { left: 100%; }
304
 
305
  .bw-radio-group { display:flex; align-items:flex-start; gap: 10px; flex-flow: row; }
 
1032
  <style>
1033
  .bw-incorrect-guesses {
1034
  font-size: 0.7rem;
1035
+ color: #ff9999;
1036
  margin-top: -10px;
1037
+ #padding: 4px 8px;
1038
+ #background: rgba(255, 255, 255, 0.05);
1039
+ #border-radius: 4px;
1040
+ font-style: italic;
1041
+ }
1042
+ .stTooltipIcon {
1043
+ position: absolute;
1044
+ left: 0;
1045
+ bottom: -22px;
1046
+ }
1047
+ .stForm {
1048
+ padding-bottom: 30px;
1049
+ }
1050
+ @media (max-width: 640px) {
1051
+ .st-emotion-cache-1xwdq91, .st-emotion-cache-1r70o5b {max-width: max-content; min-width:33%;}
1052
  }
1053
  </style>
1054
  """,
 
1063
  value="",
1064
  max_chars=10,
1065
  width=200,
1066
+ key="guess_input",
1067
+ help=tooltip_text, # Use Streamlit's built-in help parameter for tooltip
1068
  )
1069
  with col2:
1070
  submitted = st.form_submit_button("OK", disabled=not state.can_guess, width=100, key="guess_submit")
1071
 
1072
  # Show compact list below input if setting is enabled
1073
+ #if st.session_state.get("show_incorrect_guesses", False) and recent_incorrect:
1074
+ # st.markdown(
1075
+ # f'<div class="bw-incorrect-guesses">Recent: {", ".join(recent_incorrect)}</div>',
1076
+ # unsafe_allow_html=True,
1077
+ # )
1078
 
1079
  if submitted:
1080
  correct, _ = guess_word(state, guess_text)
 
1083
  if correct:
1084
  st.session_state.radar_gif_path = None
1085
  st.session_state.radar_gif_signature = None
1086
+ play_sound_effect("correct_guess", volume=0.6)
1087
  else:
1088
  # Update incorrect guesses list - keep only last 10
1089
  st.session_state.incorrect_guesses.append(guess_text)
1090
  st.session_state.incorrect_guesses = st.session_state.incorrect_guesses[-10:]
1091
+ play_sound_effect("incorrect_guess", volume=0.5)
1092
  st.rerun()
1093
 
1094
 
 
1159
  .bold-text {{ font-weight: 700; }}
1160
  .blue-background {{ background:#1d64c8; opacity:0.9; color:#fff; }}
1161
  .shiny-border {{ position: relative; padding: 12px; background: #333; color: white; border-radius: 1.25rem; overflow: hidden; }}
1162
+ .bw-score-panel-container {{ height: 100%; overflow: hidden; text-align:center;}}
1163
+ .bw-score-panel-container table tbody tr h3 {{display: flex;flex-direction: row;justify-content: space-evenly;flex-wrap: wrap;}}
1164
  table {{ width: 100%; margin: 0 auto; border-collapse: separate; border-spacing: 0; }}
1165
  th, td {{ padding: 6px 8px; }}
1166
  </style>
 
1226
  if os.path.exists(congrats_music_path):
1227
  src_url = _load_audio_data_url(congrats_music_path)
1228
  # Play once (no loop) at configured volume
1229
+ _mount_background_audio(enabled=True,src_data_url=src_url, volume=(st.session_state.get("music_volume", 100)) / 100, loop=False)
1230
  else:
1231
  _mount_background_audio(False, None, 0.0)
1232
 
 
1260
  "<th scope=\"col\">Extra</th>"
1261
  "</tr></thead>"
1262
  f"<tbody>{''.join(word_rows)}"
1263
+ f"<tr><td colspan=\"3\"><h5 class=\"m-2\">Total: {state.score} <span style='font-size:1.25rem; color:#1d64c8;'>&nbsp;⏱ {timer_str}</span></h5></td></tr>"
1264
  "</tbody>"
1265
  "</table>"
1266
  )
 
1284
  min-width: unset !important;
1285
  margin: 25px auto 0;
1286
  }
1287
+ .m-2 {display: flex;flex-direction: row;justify-content: space-evenly;flex-wrap: wrap;font-size: 1.25rem; font-weight: bold;}
1288
  .st-key-new_game_btn_dialog button, .st-key-close_game_over button {
1289
  height: 50px !important;
1290
  }
 
1346
  congrats_music_path = os.path.join(music_dir, "congratulations.mp3")
1347
  if os.path.exists(congrats_music_path):
1348
  src_url = _load_audio_data_url(congrats_music_path)
1349
+ _mount_background_audio(enabled=True, src_data_url=src_url, volume=(st.session_state.get("music_volume", 100)) / 100, loop=False)
1350
  else:
1351
  _mount_background_audio(False, None, 0.0)
1352
  _game_over_dialog(state)