Merge pull request #123 from Benefit-Zebra/master

BombSquad Exclusive Emojis
This commit is contained in:
Eric Froemling 2020-07-21 23:41:29 -07:00 committed by GitHub
commit 90651d00d8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 125 additions and 7 deletions

View File

@ -12,6 +12,8 @@
- Default widget 'show_buffer' is now 20 instead of 0 (causes scrolling to stay slightly ahead of widget selection). This can be overridden with the ba.widget() call if anything breaks.
- Relocated ba.app.uiscale to ba.app.ui.uiscale
- Top level settings window now properly saves/restores its state again.
- BombSquad now has its own Exclusive Emojis in the Internal Game Keyboard.
- Added continuos CAPITAL letters typing feature in the Internal Game Keyboard.
### 1.5.22 (20139)
- Button and key names now display correctly again on Android (and are cleaned up on other platforms too).

View File

@ -26,6 +26,8 @@ from typing import TYPE_CHECKING, cast
import _ba
import ba
from ba import charstr
from ba import SpecialChar as SpCh
if TYPE_CHECKING:
from typing import List, Tuple, Optional
@ -86,9 +88,12 @@ class OnScreenKeyboardWindow(ba.Window):
always_show_carat=True)
self._shift_button = None
self._double_press_shift = False
self._num_mode_button = None
self._emoji_button = None
self._char_keys: List[ba.Widget] = []
self._mode = 'normal'
self._last_mode = 'normal'
v = self._height - 180
key_width = 46
@ -125,7 +130,7 @@ class OnScreenKeyboardWindow(ba.Window):
autoselect=True,
textcolor=key_textcolor,
color=key_color_dark,
label=ba.charstr(ba.SpecialChar.SHIFT),
label=charstr(SpCh.SHIFT),
enable_sound=False,
extra_touch_border_scale=0.3,
button_type='square',
@ -157,7 +162,7 @@ class OnScreenKeyboardWindow(ba.Window):
repeat=True,
textcolor=key_textcolor,
color=key_color_dark,
label=ba.charstr(ba.SpecialChar.DELETE),
label=charstr(SpCh.DELETE),
button_type='square',
on_activate_call=self._del)
v -= (key_height + 9)
@ -176,6 +181,19 @@ class OnScreenKeyboardWindow(ba.Window):
color=key_color_dark,
label='',
)
if self._emoji_button is None:
self._emoji_button = ba.buttonwidget(
parent=self._root_widget,
position=(56, v - 8),
size=(key_width, key_height + 5),
autoselect=True,
enable_sound=False,
textcolor=key_textcolor,
color=key_color_dark,
label=charstr(SpCh.LOGO_FLAT),
extra_touch_border_scale=0.3,
button_type='square',
)
btn1 = self._num_mode_button
btn2 = ba.buttonwidget(parent=self._root_widget,
position=(210, v - 12),
@ -188,10 +206,12 @@ class OnScreenKeyboardWindow(ba.Window):
label=ba.Lstr(resource='spaceKeyText'),
on_activate_call=ba.Call(
self._type_char, ' '))
ba.widget(edit=btn1, right_widget=btn2)
btn3 = self._emoji_button
ba.widget(edit=btn1, right_widget=btn2, left_widget=btn3)
ba.widget(edit=btn2,
left_widget=btn1,
right_widget=self._done_button)
ba.widget(edit=btn3, left_widget=btn1)
ba.widget(edit=self._done_button, left_widget=btn2)
ba.containerwidget(edit=self._root_widget,
@ -212,11 +232,15 @@ class OnScreenKeyboardWindow(ba.Window):
ba.buttonwidget(edit=self._shift_button,
color=self._key_color_lit
if self._mode == 'caps' else self._key_color_dark,
label=ba.charstr(ba.SpecialChar.SHIFT),
label=charstr(SpCh.SHIFT),
on_activate_call=self._shift)
ba.buttonwidget(edit=self._num_mode_button,
label='123#&*',
on_activate_call=self._num_mode)
ba.buttonwidget(edit=self._emoji_button,
color=self._key_color_dark,
label=charstr(SpCh.LOGO_FLAT),
on_activate_call=self._emoji_mode)
elif self._mode == 'num':
chars = [
'1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '-', '/',
@ -230,6 +254,76 @@ class OnScreenKeyboardWindow(ba.Window):
ba.buttonwidget(edit=self._num_mode_button,
label='abc',
on_activate_call=self._abc_mode)
ba.buttonwidget(edit=self._emoji_button,
color=self._key_color_dark,
label=charstr(SpCh.LOGO_FLAT),
on_activate_call=self._emoji_mode)
elif self._mode in ['emoji', 'emoji2']:
chars = [
'💣',
'💥',
'🙂',
'😄',
'😆',
'😅',
'😂',
'',
'😀',
'😉',
'😇',
'😎',
'😰',
'😠',
'😈',
'😨',
'😛',
'😜',
'😝',
'😐',
'😑',
'😵',
'😬',
'😡',
'😌',
'😍']
if self._mode == 'emoji2':
chars = [
'😔',
'😥',
'😭',
'😖',
'😓',
'😉',
'😴',
'😷',
'👋',
'💯',
'🙏',
'💪',
'👀',
'💬',
'💀',
'',
'💩',
'👻',
'👽',
'👾',
'',
'💛',
'💚',
'💙',
'💜',
'💔']
ba.buttonwidget(edit=self._shift_button,
color=self._key_color_lit
if self._mode == 'emoji2' else self._key_color_dark,
label=charstr(SpCh.SHIFT),
on_activate_call=self._emoji_mode_2)
ba.buttonwidget(edit=self._emoji_button,
color=self._key_color_lit,
label=charstr(SpCh.LOGO_FLAT),
on_activate_call=self._emoji_mode)
for i, btn in enumerate(self._char_keys):
assert chars is not None
@ -251,12 +345,33 @@ class OnScreenKeyboardWindow(ba.Window):
self._mode = 'num'
self._refresh()
def _emoji_mode(self) -> None:
ba.playsound(self._click_sound)
if self._mode in ['normal', 'caps', 'num']:
self._last_mode = self._mode
self._mode = 'emoji'
elif self._mode == 'emoji' or self._mode == 'emoji2':
self._mode = self._last_mode
self._refresh()
def _emoji_mode_2(self) -> None:
ba.playsound(self._click_sound)
if self._mode == 'emoji':
self._mode = 'emoji2'
elif self._mode == 'emoji2':
self._mode = 'emoji'
self._refresh()
def _shift(self) -> None:
ba.playsound(self._click_sound)
if self._mode == 'normal':
self._mode = 'caps'
self._double_press_shift = False
elif self._mode == 'caps':
self._mode = 'normal'
if not self._double_press_shift:
self._double_press_shift = True
else:
self._mode = 'normal'
self._refresh()
def _del(self) -> None:
@ -273,8 +388,9 @@ class OnScreenKeyboardWindow(ba.Window):
txt = cast(str, ba.textwidget(query=self._text_field))
txt += char
ba.textwidget(edit=self._text_field, text=txt)
# if we were caps, go back
if self._mode == 'caps':
# if we were caps,
# go back only if not Shift is pressed twice
if self._mode == 'caps' and not self._double_press_shift:
self._mode = 'normal'
self._refresh()