| 1 | /* |
| 2 | * Copyright 2020-2024 Andrey Kutejko <[email protected]> |
| 3 | * |
| 4 | * This program is free software; you can redistribute it and/or modify |
| 5 | * it under the terms of the GNU General Public License as published by |
| 6 | * the Free Software Foundation; either version 3 of the License, or |
| 7 | * (at your option) any later version. |
| 8 | * |
| 9 | * This program is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | * GNU General Public License for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU General Public License |
| 15 | * along with this program; if not, see <http://www.gnu.org/licenses/>. |
| 16 | * |
| 17 | * For more details see the file COPYING. |
| 18 | */ |
| 19 | |
| 20 | use craterust-analyzer cargo gnome-robots 50.0.0 crate/::{ |
| 21 | animationrust-analyzer cargo gnome-robots 50.0.0 animation/::InfiniteAnimationrust-analyzer cargo gnome-robots 50.0.0 animation/InfiniteAnimation#, |
| 22 | arenarust-analyzer cargo gnome-robots 50.0.0 arena/::ObjectTyperust-analyzer cargo gnome-robots 50.0.0 arena/ObjectType#, |
| 23 | assetsrust-analyzer cargo gnome-robots 50.0.0 assets/::Assetsrust-analyzer cargo gnome-robots 50.0.0 assets/Assets#, |
| 24 | gamerust-analyzer cargo gnome-robots 50.0.0 game/::{Gamerust-analyzer cargo gnome-robots 50.0.0 game/Game#, GameEventrust-analyzer cargo gnome-robots 50.0.0 game/GameEvent#, MoveSafetyrust-analyzer cargo gnome-robots 50.0.0 game/MoveSafety#, PlayerCommandrust-analyzer cargo gnome-robots 50.0.0 game/PlayerCommand#, Staterust-analyzer cargo gnome-robots 50.0.0 game/State#}, |
| 25 | game_configrust-analyzer cargo gnome-robots 50.0.0 game_config/::{GameConfigrust-analyzer cargo gnome-robots 50.0.0 game_config/GameConfig#, GameConfigsrust-analyzer cargo gnome-robots 50.0.0 game_config/GameConfigs#}, |
| 26 | graphicsrust-analyzer cargo gnome-robots 50.0.0 graphics/::calculate_contrast_colorrust-analyzer cargo gnome-robots 50.0.0 graphics/calculate_contrast_color()., |
| 27 | propertiesrust-analyzer cargo gnome-robots 50.0.0 properties/::{CONTROL_KEYSrust-analyzer cargo gnome-robots 50.0.0 properties/CONTROL_KEYS., Propertiesrust-analyzer cargo gnome-robots 50.0.0 properties/Properties#}, |
| 28 | scoresrust-analyzer cargo gnome-robots 50.0.0 scores/::scoresrust-analyzer cargo gnome-robots 50.0.0 scores/scores/::{Categoryrust-analyzer cargo gnome-robots 50.0.0 scores/scores/Category#, add_scorerust-analyzer cargo gnome-robots 50.0.0 scores/scores/add_score().}, |
| 29 | sound_playerrust-analyzer cargo gnome-robots 50.0.0 sound_player/::{Soundrust-analyzer cargo gnome-robots 50.0.0 sound_player/Sound#, SoundPlayerrust-analyzer cargo gnome-robots 50.0.0 sound_player/SoundPlayer#}, |
| 30 | themerust-analyzer cargo gnome-robots 50.0.0 theme/::Themerust-analyzer cargo gnome-robots 50.0.0 theme/Theme#, |
| 31 | themesrust-analyzer cargo gnome-robots 50.0.0 themes/, |
| 32 | utilsrust-analyzer cargo gnome-robots 50.0.0 utils/::settings_aware_widgetrust-analyzer cargo gnome-robots 50.0.0 utils/settings_aware_widget()., |
| 33 | }; |
| 34 | use gettextrsrust-analyzer cargo gettext-rs 0.7.7 crate/::gettextrust-analyzer cargo gettext-rs 0.7.7 gettext().; |
| 35 | use gtkrust-analyzer cargo gtk4 0.11.1 crate/::{gdkrust-analyzer cargo gdk4 0.11.1 crate/, giorust-analyzer cargo gio 0.22.2 crate/, glibrust-analyzer cargo glib 0.22.3 crate/, graphenerust-analyzer cargo graphene-rs 0.22.0 crate/, preluderust-analyzer cargo gtk4 0.11.1 prelude/::*, subclassrust-analyzer cargo gtk4 0.11.1 subclass/::preluderust-analyzer cargo gtk4 0.11.1 subclass/prelude/::*}; |
| 36 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::{cellrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/::Refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/Ref#, errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std error/::Errorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error#, f64rust-analyzer cargo std https://github.com/rust-lang/rust/library/std f64/::constsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core f64/consts/::PIrust-analyzer cargo core https://github.com/rust-lang/rust/library/core f64/consts/PI., rcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc rc/::Rcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc rc/Rc#, timerust-analyzer cargo std https://github.com/rust-lang/rust/library/std time/::Durationrust-analyzer cargo core https://github.com/rust-lang/rust/library/core time/Duration#}; |
| 37 | |
| 38 | const MINIMUM_TILE_WIDTHrust-analyzer cargo gnome-robots 50.0.0 game_area/MINIMUM_TILE_WIDTH.: u32 = 8; |
| 39 | const MINIMUM_TILE_HEIGHTrust-analyzer cargo gnome-robots 50.0.0 game_area/MINIMUM_TILE_HEIGHT.: u32 = 8; |
| 40 | const ANIMATION_DELAY_MILLISrust-analyzer cargo gnome-robots 50.0.0 game_area/ANIMATION_DELAY_MILLIS.: u64 = 100; |
| 41 | const ANIMATION_DELAYrust-analyzer cargo gnome-robots 50.0.0 game_area/ANIMATION_DELAY.: Durationrust-analyzer cargo core https://github.com/rust-lang/rust/library/core time/Duration# = Durationrust-analyzer cargo core https://github.com/rust-lang/rust/library/core time/Duration#::from_millisrust-analyzer cargo core https://github.com/rust-lang/rust/library/core time/impl#[Duration]from_millis().(ANIMATION_DELAY_MILLISrust-analyzer cargo gnome-robots 50.0.0 game_area/ANIMATION_DELAY_MILLIS.); |
| 42 | |
| 43 | mod imprust-analyzer cargo gnome-robots 50.0.0 game_area/imp/ { |
| 44 | use superrust-analyzer cargo gnome-robots 50.0.0 game_area/::*; |
| 45 | use craterust-analyzer cargo gnome-robots 50.0.0 crate/::arenarust-analyzer cargo gnome-robots 50.0.0 arena/::Positionrust-analyzer cargo gnome-robots 50.0.0 arena/Position#; |
| 46 | use craterust-analyzer cargo gnome-robots 50.0.0 crate/::gamerust-analyzer cargo gnome-robots 50.0.0 game/::Staterust-analyzer cargo gnome-robots 50.0.0 game/State#; |
| 47 | use craterust-analyzer cargo gnome-robots 50.0.0 crate/::slotrust-analyzer cargo gnome-robots 50.0.0 slot/::ListenerIdrust-analyzer cargo gnome-robots 50.0.0 slot/ListenerId#; |
| 48 | use craterust-analyzer cargo gnome-robots 50.0.0 crate/::themerust-analyzer cargo gnome-robots 50.0.0 theme/::{ |
| 49 | player_animationrust-analyzer cargo gnome-robots 50.0.0 theme/player_animation()., player_dead_animationrust-analyzer cargo gnome-robots 50.0.0 theme/player_dead_animation()., robot1_animationrust-analyzer cargo gnome-robots 50.0.0 theme/robot1_animation()., robot2_animationrust-analyzer cargo gnome-robots 50.0.0 theme/robot2_animation()., |
| 50 | }; |
| 51 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::cellrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/::{Cellrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/Cell#, OnceCellrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/once/OnceCell#, RefCellrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/RefCell#}; |
| 52 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::syncrust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/::OnceLockrust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/once_lock/OnceLock#; |
| 53 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::timerust-analyzer cargo std https://github.com/rust-lang/rust/library/std time/::{SystemTimerust-analyzer cargo std https://github.com/rust-lang/rust/library/std time/SystemTime#, UNIX_EPOCHrust-analyzer cargo std https://github.com/rust-lang/rust/library/std time/UNIX_EPOCH.}; |
| 54 | |
| 55 | pub struct GameArearust-analyzer cargo gnome-robots 50.0.0 game_area/imp/GameArea# { |
| 56 | pub gamerust-analyzer cargo gnome-robots 50.0.0 game_area/imp/GameArea#game.: RefCellrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/RefCell#<Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Gamerust-analyzer cargo gnome-robots 50.0.0 game/Game#>>, |
| 57 | pub game_listener_idrust-analyzer cargo gnome-robots 50.0.0 game_area/imp/GameArea#game_listener_id.: Cellrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/Cell#<Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<ListenerIdrust-analyzer cargo gnome-robots 50.0.0 slot/ListenerId#>>, |
| 58 | pub game_configsrust-analyzer cargo gnome-robots 50.0.0 game_area/imp/GameArea#game_configs.: OnceCellrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/once/OnceCell#<GameConfigsrust-analyzer cargo gnome-robots 50.0.0 game_config/GameConfigs#>, |
| 59 | pub assetsrust-analyzer cargo gnome-robots 50.0.0 game_area/imp/GameArea#assets.: OnceCellrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/once/OnceCell#<Rcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc rc/Rc#<dyn Assetsrust-analyzer cargo gnome-robots 50.0.0 assets/Assets#>>, |
| 60 | pub themerust-analyzer cargo gnome-robots 50.0.0 game_area/imp/GameArea#theme.: RefCellrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/RefCell#<Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Themerust-analyzer cargo gnome-robots 50.0.0 theme/Theme#>>, |
| 61 | pub background_colorrust-analyzer cargo gnome-robots 50.0.0 game_area/imp/GameArea#background_color.: RefCellrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/RefCell#<gdkrust-analyzer cargo gdk4 0.11.1 crate/::RGBArust-analyzer cargo gdk4 0.11.1 auto/rgba/RGBA#>, |
| 62 | pub alternate_background_colorrust-analyzer cargo gnome-robots 50.0.0 game_area/imp/GameArea#alternate_background_color.: RefCellrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/RefCell#<gdkrust-analyzer cargo gdk4 0.11.1 crate/::RGBArust-analyzer cargo gdk4 0.11.1 auto/rgba/RGBA#>, |
| 63 | pub timer_idrust-analyzer cargo gnome-robots 50.0.0 game_area/imp/GameArea#timer_id.: Cellrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/Cell#<Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<glibrust-analyzer cargo glib 0.22.3 crate/::SourceIdrust-analyzer cargo glib 0.22.3 source/SourceId#>>, |
| 64 | pub player_animationrust-analyzer cargo gnome-robots 50.0.0 game_area/imp/GameArea#player_animation.: Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<dyn InfiniteAnimationrust-analyzer cargo gnome-robots 50.0.0 animation/InfiniteAnimation#>, |
| 65 | pub player_dead_animationrust-analyzer cargo gnome-robots 50.0.0 game_area/imp/GameArea#player_dead_animation.: Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<dyn InfiniteAnimationrust-analyzer cargo gnome-robots 50.0.0 animation/InfiniteAnimation#>, |
| 66 | pub robot1_animationrust-analyzer cargo gnome-robots 50.0.0 game_area/imp/GameArea#robot1_animation.: Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<dyn InfiniteAnimationrust-analyzer cargo gnome-robots 50.0.0 animation/InfiniteAnimation#>, |
| 67 | pub robot2_animationrust-analyzer cargo gnome-robots 50.0.0 game_area/imp/GameArea#robot2_animation.: Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<dyn InfiniteAnimationrust-analyzer cargo gnome-robots 50.0.0 animation/InfiniteAnimation#>, |
| 68 | pub sound_playerrust-analyzer cargo gnome-robots 50.0.0 game_area/imp/GameArea#sound_player.: SoundPlayerrust-analyzer cargo gnome-robots 50.0.0 sound_player/SoundPlayer#, |
| 69 | pub settingsrust-analyzer cargo gnome-robots 50.0.0 game_area/imp/GameArea#settings.: OnceCellrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/once/OnceCell#<giorust-analyzer cargo gio 0.22.2 crate/::Settingsrust-analyzer cargo gio 0.22.2 auto/settings/Settings#>, |
| 70 | } |
| 71 | |
| 72 | #[glibrust-analyzer cargo glib 0.22.3 crate/::object_subclassrust-analyzer cargo glib-macros 0.22.2 object_subclass:] |
| 73 | impl ObjectSubclassrust-analyzer cargo glib 0.22.3 subclass/types/ObjectSubclass# for GameArearust-analyzer cargo gnome-robots 50.0.0 game_area/imp/GameArea# { |
| 74 | const NAMErust-analyzer cargo gnome-robots 50.0.0 game_area/imp/impl#[GameArea][ObjectSubclass]NAME.: &'static str = "RobotsGameArea"; |
| 75 | type Typerust-analyzer cargo gnome-robots 50.0.0 game_area/imp/impl#[GameArea][ObjectSubclass]Type# = superrust-analyzer cargo gnome-robots 50.0.0 game_area/::GameArearust-analyzer cargo gnome-robots 50.0.0 game_area/GameArea#; |
| 76 | type ParentTyperust-analyzer cargo gnome-robots 50.0.0 game_area/imp/impl#[GameArea][ObjectSubclass]ParentType# = gtkrust-analyzer cargo gtk4 0.11.1 crate/::Widgetrust-analyzer cargo gtk4 0.11.1 auto/widget/Widget#; |
| 77 | |
| 78 | fn newrust-analyzer cargo gnome-robots 50.0.0 game_area/imp/impl#[GameArea][ObjectSubclass]new().() -> Selfrust-analyzer cargo gnome-robots 50.0.0 game_area/imp/impl#[GameArea][ObjectSubclass] { |
| 79 | Selfrust-analyzer cargo gnome-robots 50.0.0 game_area/imp/impl#[GameArea][ObjectSubclass] { |
| 80 | gamerust-analyzer cargo gnome-robots 50.0.0 game_area/imp/GameArea#game.: Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default#::defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/impl#[`RefCell<T>`][Default]default().(), |
| 81 | game_listener_idrust-analyzer cargo gnome-robots 50.0.0 game_area/imp/GameArea#game_listener_id.: Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default#::defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/impl#[`Cell<T>`][Default]default().(), |
| 82 | game_configsrust-analyzer cargo gnome-robots 50.0.0 game_area/imp/GameArea#game_configs.: Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default#::defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/once/impl#[`OnceCell<T>`][Default]default().(), |
| 83 | assetsrust-analyzer cargo gnome-robots 50.0.0 game_area/imp/GameArea#assets.: Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default#::defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/once/impl#[`OnceCell<T>`][Default]default().(), |
| 84 | themerust-analyzer cargo gnome-robots 50.0.0 game_area/imp/GameArea#theme.: Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default#::defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/impl#[`RefCell<T>`][Default]default().(), |
| 85 | background_colorrust-analyzer cargo gnome-robots 50.0.0 game_area/imp/GameArea#background_color.: RefCellrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/RefCell#::newrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/impl#[`RefCell<T>`]new().(gdkrust-analyzer cargo gdk4 0.11.1 crate/::RGBArust-analyzer cargo gdk4 0.11.1 auto/rgba/RGBA#::BLUErust-analyzer cargo gdk4 0.11.1 rgba/impl#[RGBA]BLUE.), |
| 86 | alternate_background_colorrust-analyzer cargo gnome-robots 50.0.0 game_area/imp/GameArea#alternate_background_color.: RefCellrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/RefCell#::newrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/impl#[`RefCell<T>`]new().(gdkrust-analyzer cargo gdk4 0.11.1 crate/::RGBArust-analyzer cargo gdk4 0.11.1 auto/rgba/RGBA#::GREENrust-analyzer cargo gdk4 0.11.1 rgba/impl#[RGBA]GREEN.), |
| 87 | timer_idrust-analyzer cargo gnome-robots 50.0.0 game_area/imp/GameArea#timer_id.: Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default#::defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/impl#[`Cell<T>`][Default]default().(), |
| 88 | |
| 89 | player_animationrust-analyzer cargo gnome-robots 50.0.0 game_area/imp/GameArea#player_animation.: Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/impl#[`Box<T>`]new().(player_animationrust-analyzer cargo gnome-robots 50.0.0 theme/player_animation().()), |
| 90 | player_dead_animationrust-analyzer cargo gnome-robots 50.0.0 game_area/imp/GameArea#player_dead_animation.: Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/impl#[`Box<T>`]new().(player_dead_animationrust-analyzer cargo gnome-robots 50.0.0 theme/player_dead_animation().()), |
| 91 | robot1_animationrust-analyzer cargo gnome-robots 50.0.0 game_area/imp/GameArea#robot1_animation.: Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/impl#[`Box<T>`]new().(robot1_animationrust-analyzer cargo gnome-robots 50.0.0 theme/robot1_animation().()), |
| 92 | robot2_animationrust-analyzer cargo gnome-robots 50.0.0 game_area/imp/GameArea#robot2_animation.: Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/impl#[`Box<T>`]new().(robot2_animationrust-analyzer cargo gnome-robots 50.0.0 theme/robot2_animation().()), |
| 93 | |
| 94 | sound_playerrust-analyzer cargo gnome-robots 50.0.0 game_area/imp/GameArea#sound_player.: SoundPlayerrust-analyzer cargo gnome-robots 50.0.0 sound_player/SoundPlayer#::newrust-analyzer cargo gnome-robots 50.0.0 sound_player/impl#[SoundPlayer]new().(), |
| 95 | settingsrust-analyzer cargo gnome-robots 50.0.0 game_area/imp/GameArea#settings.: Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default#::defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/once/impl#[`OnceCell<T>`][Default]default().(), |
| 96 | } |
| 97 | } |
| 98 | } |
| 99 | |
| 100 | impl ObjectImplrust-analyzer cargo glib 0.22.3 subclass/object/ObjectImpl# for GameArearust-analyzer cargo gnome-robots 50.0.0 game_area/imp/GameArea# { |
| 101 | fn constructedrust-analyzer cargo gnome-robots 50.0.0 game_area/imp/impl#[GameArea][ObjectImpl]constructed().(&self) { |
| 102 | self.parent_constructedrust-analyzer cargo glib 0.22.3 subclass/object/ObjectImplExt#parent_constructed().(); |
| 103 | |
| 104 | let obj = self.objrust-analyzer cargo glib 0.22.3 subclass/types/impl#[T][ObjectSubclassExt]obj().(); |
| 105 | obj.set_layout_managerrust-analyzer cargo gtk4 0.11.1 auto/widget/WidgetExt#set_layout_manager().(Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(gtkrust-analyzer cargo gtk4 0.11.1 crate/::BinLayoutrust-analyzer cargo gtk4 0.11.1 auto/bin_layout/BinLayout#::newrust-analyzer cargo gtk4 0.11.1 auto/bin_layout/impl#[BinLayout]new().())); |
| 106 | |
| 107 | obj.set_focusablerust-analyzer cargo gtk4 0.11.1 auto/widget/WidgetExt#set_focusable().(true); |
| 108 | obj.set_focus_on_clickrust-analyzer cargo gtk4 0.11.1 auto/widget/WidgetExt#set_focus_on_click().(true); |
| 109 | |
| 110 | let click_controller = gtkrust-analyzer cargo gtk4 0.11.1 crate/::GestureClickrust-analyzer cargo gtk4 0.11.1 auto/gesture_click/GestureClick#::newrust-analyzer cargo gtk4 0.11.1 auto/gesture_click/impl#[GestureClick]new().(); |
| 111 | click_controller.connect_pressedrust-analyzer cargo gtk4 0.11.1 auto/gesture_click/impl#[GestureClick]connect_pressed().(glibrust-analyzer cargo glib 0.22.3 crate/::clonerust-analyzer cargo glib-macros 0.22.2 clone!!( |
| 112 | #[weak] |
| 113 | obj, |
| 114 | move |_, n_pressed, x, y| obj.mouse_cbrust-analyzer cargo gnome-robots 50.0.0 game_area/impl#[GameArea]mouse_cb().(n_pressed, x, y) |
| 115 | )); |
| 116 | obj.add_controllerrust-analyzer cargo gtk4 0.11.1 auto/widget/WidgetExt#add_controller().(click_controller); |
| 117 | |
| 118 | let motion_controller = gtkrust-analyzer cargo gtk4 0.11.1 crate/::EventControllerMotionrust-analyzer cargo gtk4 0.11.1 auto/event_controller_motion/EventControllerMotion#::newrust-analyzer cargo gtk4 0.11.1 auto/event_controller_motion/impl#[EventControllerMotion]new().(); |
| 119 | motion_controller.connect_motionrust-analyzer cargo gtk4 0.11.1 auto/event_controller_motion/impl#[EventControllerMotion]connect_motion().(glibrust-analyzer cargo glib 0.22.3 crate/::clonerust-analyzer cargo glib-macros 0.22.2 clone!!( |
| 120 | #[weak] |
| 121 | obj, |
| 122 | move |_, x, y| obj.move_cbrust-analyzer cargo gnome-robots 50.0.0 game_area/impl#[GameArea]move_cb().(x, y) |
| 123 | )); |
| 124 | obj.add_controllerrust-analyzer cargo gtk4 0.11.1 auto/widget/WidgetExt#add_controller().(motion_controller); |
| 125 | |
| 126 | let key_controller = gtkrust-analyzer cargo gtk4 0.11.1 crate/::EventControllerKeyrust-analyzer cargo gtk4 0.11.1 auto/event_controller_key/EventControllerKey#::newrust-analyzer cargo gtk4 0.11.1 auto/event_controller_key/impl#[EventControllerKey]new().(); |
| 127 | key_controller.connect_key_pressedrust-analyzer cargo gtk4 0.11.1 event_controller_key/impl#[EventControllerKey]connect_key_pressed().(glibrust-analyzer cargo glib 0.22.3 crate/::clonerust-analyzer cargo glib-macros 0.22.2 clone!!( |
| 128 | #[weak] |
| 129 | obj, |
| 130 | #[upgrade_or] |
| 131 | glibrust-analyzer cargo glib 0.22.3 crate/::Propagationrust-analyzer cargo glib 0.22.3 signal/Propagation#::Proceedrust-analyzer cargo glib 0.22.3 signal/Propagation#Proceed#, |
| 132 | move |_, keyval, _keycode, state| obj.keyboard_cbrust-analyzer cargo gnome-robots 50.0.0 game_area/impl#[GameArea]keyboard_cb().(keyval, state) |
| 133 | )); |
| 134 | obj.add_controllerrust-analyzer cargo gtk4 0.11.1 auto/widget/WidgetExt#add_controller().(key_controller); |
| 135 | |
| 136 | self.timer_idrust-analyzer cargo gnome-robots 50.0.0 game_area/imp/GameArea#timer_id..setrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/impl#[`Cell<T>`]set().(Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(glibrust-analyzer cargo glib 0.22.3 crate/::timeout_add_localrust-analyzer cargo glib 0.22.3 source/timeout_add_local().( |
| 137 | ANIMATION_DELAYrust-analyzer cargo gnome-robots 50.0.0 game_area/ANIMATION_DELAY., |
| 138 | glibrust-analyzer cargo glib 0.22.3 crate/::clonerust-analyzer cargo glib-macros 0.22.2 clone!!( |
| 139 | #[strong] |
| 140 | obj, |
| 141 | move || { |
| 142 | obj.timer_cbrust-analyzer cargo gnome-robots 50.0.0 game_area/impl#[GameArea]timer_cb().(); |
| 143 | glibrust-analyzer cargo glib 0.22.3 crate/::ControlFlowrust-analyzer cargo glib 0.22.3 control_flow/ControlFlow#::Continuerust-analyzer cargo glib 0.22.3 control_flow/ControlFlow#Continue# |
| 144 | } |
| 145 | ), |
| 146 | ))); |
| 147 | } |
| 148 | |
| 149 | fn disposerust-analyzer cargo gnome-robots 50.0.0 game_area/imp/impl#[GameArea][ObjectImpl]dispose().(&self) { |
| 150 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(source_id) = self.timer_idrust-analyzer cargo gnome-robots 50.0.0 game_area/imp/GameArea#timer_id..takerust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/impl#[`Cell<T>`]take().() { |
| 151 | source_id.removerust-analyzer cargo glib 0.22.3 source/impl#[SourceId]remove().(); |
| 152 | } |
| 153 | |
| 154 | while let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(child) = self.objrust-analyzer cargo glib 0.22.3 subclass/types/impl#[T][ObjectSubclassExt]obj().().first_childrust-analyzer cargo gtk4 0.11.1 auto/widget/WidgetExt#first_child().() { |
| 155 | child.unparentrust-analyzer cargo gtk4 0.11.1 auto/widget/WidgetExt#unparent().(); |
| 156 | } |
| 157 | } |
| 158 | |
| 159 | fn signalsrust-analyzer cargo gnome-robots 50.0.0 game_area/imp/impl#[GameArea][ObjectImpl]signals().() -> &'static [glibrust-analyzer cargo glib 0.22.3 crate/::subclassrust-analyzer cargo glib 0.22.3 subclass/::Signalrust-analyzer cargo glib 0.22.3 subclass/signal/Signal#] { |
| 160 | static SIGNALSrust-analyzer cargo gnome-robots 50.0.0 game_area/imp/SIGNALS.: OnceLockrust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/once_lock/OnceLock#<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<glibrust-analyzer cargo glib 0.22.3 crate/::subclassrust-analyzer cargo glib 0.22.3 subclass/::Signalrust-analyzer cargo glib 0.22.3 subclass/signal/Signal#>> = OnceLockrust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/once_lock/OnceLock#::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/once_lock/impl#[`OnceLock<T>`]new().(); |
| 161 | SIGNALSrust-analyzer cargo gnome-robots 50.0.0 game_area/imp/SIGNALS..get_or_initrust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/once_lock/impl#[`OnceLock<T>`]get_or_init().(|| { |
| 162 | vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![ |
| 163 | glibrust-analyzer cargo glib 0.22.3 crate/::subclassrust-analyzer cargo glib 0.22.3 subclass/::Signalrust-analyzer cargo glib 0.22.3 subclass/signal/Signal#::builderrust-analyzer cargo glib 0.22.3 subclass/signal/impl#[Signal]builder().("updated") |
| 164 | .return_typerust-analyzer cargo glib 0.22.3 subclass/signal/impl#[SignalBuilder]return_type().::<()>() |
| 165 | .buildrust-analyzer cargo glib 0.22.3 subclass/signal/impl#[SignalBuilder]build().(), |
| 166 | ] |
| 167 | }) |
| 168 | } |
| 169 | } |
| 170 | |
| 171 | impl WidgetImplrust-analyzer cargo gtk4 0.11.1 subclass/widget/WidgetImpl# for GameArearust-analyzer cargo gnome-robots 50.0.0 game_area/imp/GameArea# { |
| 172 | fn snapshotrust-analyzer cargo gnome-robots 50.0.0 game_area/imp/impl#[GameArea][WidgetImpl]snapshot().(&self, snapshot: >krust-analyzer cargo gtk4 0.11.1 crate/::Snapshotrust-analyzer cargo gtk4 0.11.1 auto/snapshot/Snapshot#) { |
| 173 | let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(renderer) = self |
| 174 | .objrust-analyzer cargo glib 0.22.3 subclass/types/impl#[T][ObjectSubclassExt]obj().() |
| 175 | .rootrust-analyzer cargo gtk4 0.11.1 auto/widget/WidgetExt#root().() |
| 176 | .and_downcastrust-analyzer cargo glib 0.22.3 object/impl#[`Option<I>`][CastNone]and_downcast().::<gtkrust-analyzer cargo gtk4 0.11.1 crate/::Windowrust-analyzer cargo gtk4 0.11.1 auto/window/Window#>() |
| 177 | .and_thenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]and_then().(|w| w.rendererrust-analyzer cargo gtk4 0.11.1 auto/native/NativeExt#renderer().()) |
| 178 | else { |
| 179 | eprintlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/eprintln!!("No renderer available"); |
| 180 | return; |
| 181 | }; |
| 182 | |
| 183 | let game_ref = self.gamerust-analyzer cargo gnome-robots 50.0.0 game_area/imp/GameArea#game..borrowrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/impl#[`RefCell<T>`]borrow().(); |
| 184 | let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(game) = game_ref.as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_ref().() else { |
| 185 | return; |
| 186 | }; |
| 187 | |
| 188 | let time = SystemTimerust-analyzer cargo std https://github.com/rust-lang/rust/library/std time/SystemTime#::nowrust-analyzer cargo std https://github.com/rust-lang/rust/library/std time/impl#[SystemTime]now().() |
| 189 | .duration_sincerust-analyzer cargo std https://github.com/rust-lang/rust/library/std time/impl#[SystemTime]duration_since().(UNIX_EPOCHrust-analyzer cargo std https://github.com/rust-lang/rust/library/std time/UNIX_EPOCH.) |
| 190 | .map_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map_or().(0, |t| t.as_millisrust-analyzer cargo core https://github.com/rust-lang/rust/library/core time/impl#[Duration]as_millis().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u128][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u128][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u128][`Div<Self>`]div().ANIMATION_DELAY_MILLISrust-analyzer cargo gnome-robots 50.0.0 game_area/ANIMATION_DELAY_MILLIS. as u128) |
| 191 | as usize; |
| 192 | let tile_width = (self.objrust-analyzer cargo glib 0.22.3 subclass/types/impl#[T][ObjectSubclassExt]obj().().widthrust-analyzer cargo gtk4 0.11.1 auto/widget/WidgetExt#width().() as f64) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div().(game.widthrust-analyzer cargo gnome-robots 50.0.0 game/impl#[Game]width().() as f64); |
| 193 | let tile_height = (self.objrust-analyzer cargo glib 0.22.3 subclass/types/impl#[T][ObjectSubclassExt]obj().().heightrust-analyzer cargo gtk4 0.11.1 auto/widget/WidgetExt#height().() as f64) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div().(game.heightrust-analyzer cargo gnome-robots 50.0.0 game/impl#[Game]height().() as f64); |
| 194 | let assets = self.assetsrust-analyzer cargo gnome-robots 50.0.0 game_area/imp/GameArea#assets..getrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/once/impl#[`OnceCell<T>`]get().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(); |
| 195 | |
| 196 | for y in 0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#game.heightrust-analyzer cargo gnome-robots 50.0.0 game/impl#[Game]height().() { |
| 197 | for x in 0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#game.widthrust-analyzer cargo gnome-robots 50.0.0 game/impl#[Game]width().() { |
| 198 | let position = Positionrust-analyzer cargo gnome-robots 50.0.0 arena/Position# { xrust-analyzer cargo gnome-robots 50.0.0 arena/Position#x., yrust-analyzer cargo gnome-robots 50.0.0 arena/Position#y. }; |
| 199 | |
| 200 | let tile_rect = graphenerust-analyzer cargo graphene-rs 0.22.0 crate/::Rectrust-analyzer cargo graphene-rs 0.22.0 auto/rect/Rect#::newrust-analyzer cargo graphene-rs 0.22.0 rect/impl#[Rect]new().( |
| 201 | ((x as f64) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul().tile_width) as f32, |
| 202 | ((y as f64) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul().tile_height) as f32, |
| 203 | (tile_width) as f32, |
| 204 | (tile_height) as f32, |
| 205 | ); |
| 206 | let color = if (x rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Add<Self>`]add().y) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Rem<Self>`]rem().%rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Rem<Self>`]rem(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Rem<Self>`]rem().2 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialEq<Self>`]ne().0 { |
| 207 | self.background_colorrust-analyzer cargo gnome-robots 50.0.0 game_area/imp/GameArea#background_color..borrowrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/impl#[`RefCell<T>`]borrow().() |
| 208 | } else { |
| 209 | self.alternate_background_colorrust-analyzer cargo gnome-robots 50.0.0 game_area/imp/GameArea#alternate_background_color..borrowrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/impl#[`RefCell<T>`]borrow().() |
| 210 | }; |
| 211 | snapshot.append_colorrust-analyzer cargo gtk4 0.11.1 auto/snapshot/SnapshotExt#append_color().(&color, &tile_rect); |
| 212 | |
| 213 | let object_type = game.getrust-analyzer cargo gnome-robots 50.0.0 game/impl#[Game]get().(position); |
| 214 | let frame = match object_type { |
| 215 | ObjectTyperust-analyzer cargo gnome-robots 50.0.0 arena/ObjectType#::Playerrust-analyzer cargo gnome-robots 50.0.0 arena/ObjectType#Player# if game.staterust-analyzer cargo gnome-robots 50.0.0 game/impl#[Game]state().() rust-analyzer cargo gnome-robots 50.0.0 game/impl#[State][`PartialEq<Self>`]eq().==rust-analyzer cargo gnome-robots 50.0.0 game/impl#[State][`PartialEq<Self>`]eq(). rust-analyzer cargo gnome-robots 50.0.0 game/impl#[State][`PartialEq<Self>`]eq().Staterust-analyzer cargo gnome-robots 50.0.0 game/State#::Deadrust-analyzer cargo gnome-robots 50.0.0 game/State#Dead# => { |
| 216 | self.player_dead_animationrust-analyzer cargo gnome-robots 50.0.0 game_area/imp/GameArea#player_dead_animation..framerust-analyzer cargo gnome-robots 50.0.0 animation/InfiniteAnimation#frame().(time) |
| 217 | } |
| 218 | ObjectTyperust-analyzer cargo gnome-robots 50.0.0 arena/ObjectType#::Playerrust-analyzer cargo gnome-robots 50.0.0 arena/ObjectType#Player# => self.player_animationrust-analyzer cargo gnome-robots 50.0.0 game_area/imp/GameArea#player_animation..framerust-analyzer cargo gnome-robots 50.0.0 animation/InfiniteAnimation#frame().(time), |
| 219 | ObjectTyperust-analyzer cargo gnome-robots 50.0.0 arena/ObjectType#::Robot1rust-analyzer cargo gnome-robots 50.0.0 arena/ObjectType#Robot1# => self.robot1_animationrust-analyzer cargo gnome-robots 50.0.0 game_area/imp/GameArea#robot1_animation..framerust-analyzer cargo gnome-robots 50.0.0 animation/InfiniteAnimation#frame().(time), |
| 220 | ObjectTyperust-analyzer cargo gnome-robots 50.0.0 arena/ObjectType#::Robot2rust-analyzer cargo gnome-robots 50.0.0 arena/ObjectType#Robot2# => self.robot2_animationrust-analyzer cargo gnome-robots 50.0.0 game_area/imp/GameArea#robot2_animation..framerust-analyzer cargo gnome-robots 50.0.0 animation/InfiniteAnimation#frame().(time), |
| 221 | ObjectTyperust-analyzer cargo gnome-robots 50.0.0 arena/ObjectType#::Heaprust-analyzer cargo gnome-robots 50.0.0 arena/ObjectType#Heap# => 0, |
| 222 | ObjectTyperust-analyzer cargo gnome-robots 50.0.0 arena/ObjectType#::Nonerust-analyzer cargo gnome-robots 50.0.0 arena/ObjectType#None# => 0, |
| 223 | }; |
| 224 | self.themerust-analyzer cargo gnome-robots 50.0.0 game_area/imp/GameArea#theme..borrowrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/impl#[`RefCell<T>`]borrow().().as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_ref().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().draw_objectrust-analyzer cargo gnome-robots 50.0.0 theme/impl#[Theme]draw_object().( |
| 225 | object_type, |
| 226 | frame, |
| 227 | snapshot, |
| 228 | &tile_rect, |
| 229 | &renderer, |
| 230 | ); |
| 231 | } |
| 232 | } |
| 233 | |
| 234 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(splat) = game.splatrust-analyzer cargo gnome-robots 50.0.0 game/impl#[Game]splat().() { |
| 235 | assets.splat_bubblerust-analyzer cargo gnome-robots 50.0.0 assets/Assets#splat_bubble().().drawrust-analyzer cargo gnome-robots 50.0.0 bubble/impl#[Bubble]draw().( |
| 236 | snapshot, |
| 237 | (splat.xrust-analyzer cargo gnome-robots 50.0.0 arena/Position#x. as f64) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul().tile_width rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Add<Self>`]add().8.0, |
| 238 | (splat.yrust-analyzer cargo gnome-robots 50.0.0 arena/Position#y. as f64) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul().tile_height rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Add<Self>`]add().8.0, |
| 239 | ); |
| 240 | } |
| 241 | |
| 242 | match game.staterust-analyzer cargo gnome-robots 50.0.0 game/impl#[Game]state().() { |
| 243 | Staterust-analyzer cargo gnome-robots 50.0.0 game/State#::Deadrust-analyzer cargo gnome-robots 50.0.0 game/State#Dead# => { |
| 244 | let player = game.playerrust-analyzer cargo gnome-robots 50.0.0 game/impl#[Game]player().(); |
| 245 | assets.aieee_bubblerust-analyzer cargo gnome-robots 50.0.0 assets/Assets#aieee_bubble().().drawrust-analyzer cargo gnome-robots 50.0.0 bubble/impl#[Bubble]draw().( |
| 246 | snapshot, |
| 247 | (player.xrust-analyzer cargo gnome-robots 50.0.0 arena/Position#x. as f64) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul().tile_width rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Add<Self>`]add().8.0, |
| 248 | (player.yrust-analyzer cargo gnome-robots 50.0.0 arena/Position#y. as f64) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul().tile_height rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Add<Self>`]add().4.0, |
| 249 | ); |
| 250 | } |
| 251 | Staterust-analyzer cargo gnome-robots 50.0.0 game/State#::Completerust-analyzer cargo gnome-robots 50.0.0 game/State#Complete# => { |
| 252 | let player = game.playerrust-analyzer cargo gnome-robots 50.0.0 game/impl#[Game]player().(); |
| 253 | assets.yahoo_bubblerust-analyzer cargo gnome-robots 50.0.0 assets/Assets#yahoo_bubble().().drawrust-analyzer cargo gnome-robots 50.0.0 bubble/impl#[Bubble]draw().( |
| 254 | snapshot, |
| 255 | (player.xrust-analyzer cargo gnome-robots 50.0.0 arena/Position#x. as f64) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul().tile_width rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Add<Self>`]add().8.0, |
| 256 | (player.yrust-analyzer cargo gnome-robots 50.0.0 arena/Position#y. as f64) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul().tile_height rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Add<Self>`]add().4.0, |
| 257 | ); |
| 258 | } |
| 259 | _ => {} |
| 260 | } |
| 261 | } |
| 262 | } |
| 263 | } |
| 264 | |
| 265 | glibrust-analyzer cargo glib 0.22.3 crate/::wrapperrust-analyzer cargo glib 0.22.3 wrapper/wrapper!! { |
| 266 | pub struct GameArearust-analyzer cargo gnome-robots 50.0.0 game_area/GameArea#(ObjectSubclass<imprust-analyzer cargo gnome-robots 50.0.0 game_area/imp/::GameArearust-analyzer cargo gnome-robots 50.0.0 game_area/imp/GameArea#>) |
| 267 | @extends gtkrust-analyzer cargo gtk4 0.11.1 crate/::Widgetrust-analyzer cargo gtk4 0.11.1 auto/widget/Widget#, |
| 268 | @implements gtkrust-analyzer cargo gtk4 0.11.1 crate/::Accessiblerust-analyzer cargo gtk4 0.11.1 auto/accessible/Accessible#, gtkrust-analyzer cargo gtk4 0.11.1 crate/::Buildablerust-analyzer cargo gtk4 0.11.1 auto/buildable/Buildable#, gtkrust-analyzer cargo gtk4 0.11.1 crate/::ConstraintTargetrust-analyzer cargo gtk4 0.11.1 auto/constraint_target/ConstraintTarget#; |
| 269 | } |
| 270 | |
| 271 | impl GameArearust-analyzer cargo gnome-robots 50.0.0 game_area/GameArea# { |
| 272 | pub fn newrust-analyzer cargo gnome-robots 50.0.0 game_area/impl#[GameArea]new().( |
| 273 | game_configs: GameConfigsrust-analyzer cargo gnome-robots 50.0.0 game_config/GameConfigs#, |
| 274 | assets: &Rcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc rc/Rc#<dyn Assetsrust-analyzer cargo gnome-robots 50.0.0 assets/Assets#>, |
| 275 | settings: &giorust-analyzer cargo gio 0.22.2 crate/::Settingsrust-analyzer cargo gio 0.22.2 auto/settings/Settings#, |
| 276 | ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Selfrust-analyzer cargo gnome-robots 50.0.0 game_area/impl#[GameArea], Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<dyn Errorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error#>> { |
| 277 | let this: Selfrust-analyzer cargo gnome-robots 50.0.0 game_area/impl#[GameArea] = glibrust-analyzer cargo glib 0.22.3 crate/::Objectrust-analyzer cargo glib 0.22.3 object/Object#::builderrust-analyzer cargo glib 0.22.3 object/impl#[Object]builder().().buildrust-analyzer cargo glib 0.22.3 object/impl#[`ObjectBuilder<'a, O>`]build().(); |
| 278 | |
| 279 | this.imprust-analyzer cargo glib 0.22.3 subclass/types/impl#[T][ObjectSubclassIsExt]imp().().game_configsrust-analyzer cargo gnome-robots 50.0.0 game_area/imp/GameArea#game_configs..setrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/once/impl#[`OnceCell<T>`]set().(game_configs).okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]ok().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(); |
| 280 | this.imprust-analyzer cargo glib 0.22.3 subclass/types/impl#[T][ObjectSubclassIsExt]imp().().assetsrust-analyzer cargo gnome-robots 50.0.0 game_area/imp/GameArea#assets..setrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/once/impl#[`OnceCell<T>`]set().(assets.clonerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc rc/impl#[`Rc<T, A>`][Clone]clone().()).okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]ok().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(); |
| 281 | this.set_background_colorrust-analyzer cargo gnome-robots 50.0.0 game_area/impl#[GameArea]set_background_color().(settings.bgcolourrust-analyzer cargo gnome-robots 50.0.0 properties/impl#[`gio::Settings`][Properties]bgcolour().()); |
| 282 | *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/impl#[`RefMut<'_, T>`][DerefMut]deref_mut().this.imprust-analyzer cargo glib 0.22.3 subclass/types/impl#[T][ObjectSubclassIsExt]imp().().themerust-analyzer cargo gnome-robots 50.0.0 game_area/imp/GameArea#theme..borrow_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/impl#[`RefCell<T>`]borrow_mut().() = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(themesrust-analyzer cargo gnome-robots 50.0.0 themes/::find_best_matchrust-analyzer cargo gnome-robots 50.0.0 themes/find_best_match().( |
| 283 | &assets.themesrust-analyzer cargo gnome-robots 50.0.0 assets/Assets#themes().(), |
| 284 | &settings.themerust-analyzer cargo gnome-robots 50.0.0 properties/impl#[`gio::Settings`][Properties]theme().(), |
| 285 | )?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().); |
| 286 | this.imprust-analyzer cargo glib 0.22.3 subclass/types/impl#[T][ObjectSubclassIsExt]imp().().settingsrust-analyzer cargo gnome-robots 50.0.0 game_area/imp/GameArea#settings..setrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/once/impl#[`OnceCell<T>`]set().(settings.clonerust-analyzer cargo gio 0.22.2 auto/settings/impl#[Settings][Clone]clone().()).okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]ok().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(); |
| 287 | |
| 288 | settings_aware_widgetrust-analyzer cargo gnome-robots 50.0.0 utils/settings_aware_widget().(&this, settings, Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |ga, s| ga.properties_changed_cbrust-analyzer cargo gnome-robots 50.0.0 game_area/impl#[GameArea]properties_changed_cb().(s)); |
| 289 | |
| 290 | this.start_new_gamerust-analyzer cargo gnome-robots 50.0.0 game_area/impl#[GameArea]start_new_game().(); |
| 291 | |
| 292 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(this) |
| 293 | } |
| 294 | |
| 295 | pub fn gamerust-analyzer cargo gnome-robots 50.0.0 game_area/impl#[GameArea]game().(&self) -> Refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/Ref#<'_, Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Gamerust-analyzer cargo gnome-robots 50.0.0 game/Game#>> { |
| 296 | self.imprust-analyzer cargo glib 0.22.3 subclass/types/impl#[T][ObjectSubclassIsExt]imp().().gamerust-analyzer cargo gnome-robots 50.0.0 game_area/imp/GameArea#game..borrowrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/impl#[`RefCell<T>`]borrow().() |
| 297 | } |
| 298 | |
| 299 | pub fn set_gamerust-analyzer cargo gnome-robots 50.0.0 game_area/impl#[GameArea]set_game().(&self, game: Gamerust-analyzer cargo gnome-robots 50.0.0 game/Game#) { |
| 300 | let mut this_game = self.imprust-analyzer cargo glib 0.22.3 subclass/types/impl#[T][ObjectSubclassIsExt]imp().().gamerust-analyzer cargo gnome-robots 50.0.0 game_area/imp/GameArea#game..borrow_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/impl#[`RefCell<T>`]borrow_mut().(); |
| 301 | |
| 302 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(listener_id) = self.imprust-analyzer cargo glib 0.22.3 subclass/types/impl#[T][ObjectSubclassIsExt]imp().().game_listener_idrust-analyzer cargo gnome-robots 50.0.0 game_area/imp/GameArea#game_listener_id..takerust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/impl#[`Cell<T>`]take().() |
| 303 | && let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(game) = this_game.as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_ref().() |
| 304 | { |
| 305 | game.on_game_eventrust-analyzer cargo gnome-robots 50.0.0 game/Game#on_game_event..disconnectrust-analyzer cargo gnome-robots 50.0.0 slot/impl#[`Slot<T>`]disconnect().(listener_id); |
| 306 | } |
| 307 | |
| 308 | self.set_size_requestrust-analyzer cargo gtk4 0.11.1 auto/widget/WidgetExt#set_size_request().( |
| 309 | (MINIMUM_TILE_WIDTHrust-analyzer cargo gnome-robots 50.0.0 game_area/MINIMUM_TILE_WIDTH. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Mul<Self>`]mul().game.widthrust-analyzer cargo gnome-robots 50.0.0 game/impl#[Game]width().()) as i32, |
| 310 | (MINIMUM_TILE_HEIGHTrust-analyzer cargo gnome-robots 50.0.0 game_area/MINIMUM_TILE_HEIGHT. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Mul<Self>`]mul().game.heightrust-analyzer cargo gnome-robots 50.0.0 game/impl#[Game]height().()) as i32, |
| 311 | ); |
| 312 | |
| 313 | let game_listener_id = game.on_game_eventrust-analyzer cargo gnome-robots 50.0.0 game/Game#on_game_event..connectrust-analyzer cargo gnome-robots 50.0.0 slot/impl#[`Slot<T>`]connect().(glibrust-analyzer cargo glib 0.22.3 crate/::clonerust-analyzer cargo glib-macros 0.22.2 clone!!( |
| 314 | #[weak(rename_to = this)] |
| 315 | self, |
| 316 | move |event| { |
| 317 | let event = *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().event; |
| 318 | glibrust-analyzer cargo glib 0.22.3 crate/::MainContextrust-analyzer cargo glib 0.22.3 auto/main_context/MainContext#::defaultrust-analyzer cargo glib 0.22.3 auto/main_context/impl#[MainContext]default().().spawn_localrust-analyzer cargo glib 0.22.3 main_context_futures/impl#[MainContext]spawn_local().(async move { |
| 319 | this.on_game_eventrust-analyzer cargo gnome-robots 50.0.0 game_area/impl#[GameArea]on_game_event().(event).rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().; |
| 320 | }); |
| 321 | } |
| 322 | )); |
| 323 | *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/impl#[`RefMut<'_, T>`][DerefMut]deref_mut().this_game = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(game); |
| 324 | self.imprust-analyzer cargo glib 0.22.3 subclass/types/impl#[T][ObjectSubclassIsExt]imp().().game_listener_idrust-analyzer cargo gnome-robots 50.0.0 game_area/imp/GameArea#game_listener_id..setrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/impl#[`Cell<T>`]set().(Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(game_listener_id)); |
| 325 | } |
| 326 | |
| 327 | pub fn set_background_colorrust-analyzer cargo gnome-robots 50.0.0 game_area/impl#[GameArea]set_background_color().(&self, color: gdkrust-analyzer cargo gdk4 0.11.1 crate/::RGBArust-analyzer cargo gdk4 0.11.1 auto/rgba/RGBA#) { |
| 328 | *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/impl#[`RefMut<'_, T>`][DerefMut]deref_mut().self.imprust-analyzer cargo glib 0.22.3 subclass/types/impl#[T][ObjectSubclassIsExt]imp().().background_colorrust-analyzer cargo gnome-robots 50.0.0 game_area/imp/GameArea#background_color..borrow_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/impl#[`RefCell<T>`]borrow_mut().() = color; |
| 329 | *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/impl#[`RefMut<'_, T>`][DerefMut]deref_mut().self.imprust-analyzer cargo glib 0.22.3 subclass/types/impl#[T][ObjectSubclassIsExt]imp().().alternate_background_colorrust-analyzer cargo gnome-robots 50.0.0 game_area/imp/GameArea#alternate_background_color..borrow_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/impl#[`RefCell<T>`]borrow_mut().() = calculate_contrast_colorrust-analyzer cargo gnome-robots 50.0.0 graphics/calculate_contrast_color().(&color); |
| 330 | self.queue_drawrust-analyzer cargo gtk4 0.11.1 auto/widget/WidgetExt#queue_draw().(); |
| 331 | } |
| 332 | |
| 333 | fn timer_cbrust-analyzer cargo gnome-robots 50.0.0 game_area/impl#[GameArea]timer_cb().(&self) { |
| 334 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(game) = self.imprust-analyzer cargo glib 0.22.3 subclass/types/impl#[T][ObjectSubclassIsExt]imp().().gamerust-analyzer cargo gnome-robots 50.0.0 game_area/imp/GameArea#game..borrowrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/impl#[`RefCell<T>`]borrow().().as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_ref().() { |
| 335 | game.tickrust-analyzer cargo gnome-robots 50.0.0 game/impl#[Game]tick().(); |
| 336 | self.emit_by_namerust-analyzer cargo glib 0.22.3 object/impl#[T][ObjectExt]emit_by_name().::<()>("updated", &[]); |
| 337 | } |
| 338 | self.queue_drawrust-analyzer cargo gtk4 0.11.1 auto/widget/WidgetExt#queue_draw().(); |
| 339 | } |
| 340 | |
| 341 | fn mouse_cbrust-analyzer cargo gnome-robots 50.0.0 game_area/impl#[GameArea]mouse_cb().(&self, _n_press: i32, x: f64, y: f64) { |
| 342 | let game_ref = self.imprust-analyzer cargo glib 0.22.3 subclass/types/impl#[T][ObjectSubclassIsExt]imp().().gamerust-analyzer cargo gnome-robots 50.0.0 game_area/imp/GameArea#game..borrowrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/impl#[`RefCell<T>`]borrow().(); |
| 343 | let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(game) = game_ref.as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_ref().() else { |
| 344 | return; |
| 345 | }; |
| 346 | if game.staterust-analyzer cargo gnome-robots 50.0.0 game/impl#[Game]state().() rust-analyzer cargo gnome-robots 50.0.0 game/impl#[State][`PartialEq<Self>`]eq().==rust-analyzer cargo gnome-robots 50.0.0 game/impl#[State][`PartialEq<Self>`]eq(). rust-analyzer cargo gnome-robots 50.0.0 game/impl#[State][`PartialEq<Self>`]eq().Staterust-analyzer cargo gnome-robots 50.0.0 game/State#::Playingrust-analyzer cargo gnome-robots 50.0.0 game/State#Playing# { |
| 347 | let (dx, dy) = self.get_dirrust-analyzer cargo gnome-robots 50.0.0 game_area/impl#[GameArea]get_dir().(game, x, y); |
| 348 | let cmd = PlayerCommandrust-analyzer cargo gnome-robots 50.0.0 game/PlayerCommand#::from_directionrust-analyzer cargo gnome-robots 50.0.0 game/impl#[PlayerCommand]from_direction().(dx, dy); |
| 349 | self.player_commandrust-analyzer cargo gnome-robots 50.0.0 game_area/impl#[GameArea]player_command().(cmd); |
| 350 | } |
| 351 | } |
| 352 | |
| 353 | fn move_cbrust-analyzer cargo gnome-robots 50.0.0 game_area/impl#[GameArea]move_cb().(&self, x: f64, y: f64) { |
| 354 | let game_ref = self.imprust-analyzer cargo glib 0.22.3 subclass/types/impl#[T][ObjectSubclassIsExt]imp().().gamerust-analyzer cargo gnome-robots 50.0.0 game_area/imp/GameArea#game..borrowrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/impl#[`RefCell<T>`]borrow().(); |
| 355 | let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(game) = game_ref.as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_ref().() else { |
| 356 | return; |
| 357 | }; |
| 358 | if game.staterust-analyzer cargo gnome-robots 50.0.0 game/impl#[Game]state().() rust-analyzer cargo gnome-robots 50.0.0 game/impl#[State][`PartialEq<Self>`]eq().==rust-analyzer cargo gnome-robots 50.0.0 game/impl#[State][`PartialEq<Self>`]eq(). rust-analyzer cargo gnome-robots 50.0.0 game/impl#[State][`PartialEq<Self>`]eq().Staterust-analyzer cargo gnome-robots 50.0.0 game/State#::Playingrust-analyzer cargo gnome-robots 50.0.0 game/State#Playing# { |
| 359 | let (dx, dy) = self.get_dirrust-analyzer cargo gnome-robots 50.0.0 game_area/impl#[GameArea]get_dir().(game, x, y); |
| 360 | let cursor_index = 3 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Mul<Self>`]mul().(dy rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Add<Self>`]add().1) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Add<Self>`]add().(dx rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Add<Self>`]add().1); |
| 361 | let cursor = &self.imprust-analyzer cargo glib 0.22.3 subclass/types/impl#[T][ObjectSubclassIsExt]imp().().assetsrust-analyzer cargo gnome-robots 50.0.0 game_area/imp/GameArea#assets..getrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/once/impl#[`OnceCell<T>`]get().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().cursorsrust-analyzer cargo gnome-robots 50.0.0 assets/Assets#cursors().()[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().cursor_index as usize]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().; |
| 362 | self.set_cursorrust-analyzer cargo gtk4 0.11.1 auto/widget/WidgetExt#set_cursor().(Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(cursor)); |
| 363 | } else { |
| 364 | self.set_cursorrust-analyzer cargo gtk4 0.11.1 auto/widget/WidgetExt#set_cursor().(Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#); |
| 365 | } |
| 366 | } |
| 367 | |
| 368 | fn keyboard_cbrust-analyzer cargo gnome-robots 50.0.0 game_area/impl#[GameArea]keyboard_cb().(&self, key: gdkrust-analyzer cargo gdk4 0.11.1 crate/::Keyrust-analyzer cargo gdk4 0.11.1 keys/Key#, state: gdkrust-analyzer cargo gdk4 0.11.1 crate/::ModifierTyperust-analyzer cargo gdk4 0.11.1 auto/flags/ModifierType#) -> glibrust-analyzer cargo glib 0.22.3 crate/::Propagationrust-analyzer cargo glib 0.22.3 signal/Propagation# { |
| 369 | const NO_MODrust-analyzer cargo gnome-robots 50.0.0 game_area/NO_MOD.: gdkrust-analyzer cargo gdk4 0.11.1 crate/::ModifierTyperust-analyzer cargo gdk4 0.11.1 auto/flags/ModifierType# = gdkrust-analyzer cargo gdk4 0.11.1 crate/::ModifierTyperust-analyzer cargo gdk4 0.11.1 auto/flags/ModifierType#::NO_MODIFIER_MASKrust-analyzer cargo gdk4 0.11.1 auto/flags/impl#[ModifierType]NO_MODIFIER_MASK.; |
| 370 | const CTRLrust-analyzer cargo gnome-robots 50.0.0 game_area/CTRL.: gdkrust-analyzer cargo gdk4 0.11.1 crate/::ModifierTyperust-analyzer cargo gdk4 0.11.1 auto/flags/ModifierType# = gdkrust-analyzer cargo gdk4 0.11.1 crate/::ModifierTyperust-analyzer cargo gdk4 0.11.1 auto/flags/ModifierType#::CONTROL_MASKrust-analyzer cargo gdk4 0.11.1 auto/flags/impl#[ModifierType]CONTROL_MASK.; |
| 371 | |
| 372 | let command = match (state, key) { |
| 373 | (NO_MODrust-analyzer cargo gnome-robots 50.0.0 game_area/NO_MOD., gdkrust-analyzer cargo gdk4 0.11.1 crate/::Keyrust-analyzer cargo gdk4 0.11.1 keys/Key#::KP_0rust-analyzer cargo gdk4 0.11.1 keys/impl#[Key]KP_0. | gdkrust-analyzer cargo gdk4 0.11.1 crate/::Keyrust-analyzer cargo gdk4 0.11.1 keys/Key#::KP_Insertrust-analyzer cargo gdk4 0.11.1 keys/impl#[Key]KP_Insert.) => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(PlayerCommandrust-analyzer cargo gnome-robots 50.0.0 game/PlayerCommand#::RandomTeleportrust-analyzer cargo gnome-robots 50.0.0 game/PlayerCommand#RandomTeleport#), |
| 374 | (CTRLrust-analyzer cargo gnome-robots 50.0.0 game_area/CTRL., gdkrust-analyzer cargo gdk4 0.11.1 crate/::Keyrust-analyzer cargo gdk4 0.11.1 keys/Key#::KP_0rust-analyzer cargo gdk4 0.11.1 keys/impl#[Key]KP_0. | gdkrust-analyzer cargo gdk4 0.11.1 crate/::Keyrust-analyzer cargo gdk4 0.11.1 keys/Key#::KP_Insertrust-analyzer cargo gdk4 0.11.1 keys/impl#[Key]KP_Insert.) => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(PlayerCommandrust-analyzer cargo gnome-robots 50.0.0 game/PlayerCommand#::SafeTeleportrust-analyzer cargo gnome-robots 50.0.0 game/PlayerCommand#SafeTeleport#), |
| 375 | (NO_MODrust-analyzer cargo gnome-robots 50.0.0 game_area/NO_MOD., gdkrust-analyzer cargo gdk4 0.11.1 crate/::Keyrust-analyzer cargo gdk4 0.11.1 keys/Key#::KP_1rust-analyzer cargo gdk4 0.11.1 keys/impl#[Key]KP_1. | gdkrust-analyzer cargo gdk4 0.11.1 crate/::Keyrust-analyzer cargo gdk4 0.11.1 keys/Key#::KP_Endrust-analyzer cargo gdk4 0.11.1 keys/impl#[Key]KP_End.) => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(PlayerCommandrust-analyzer cargo gnome-robots 50.0.0 game/PlayerCommand#::SWrust-analyzer cargo gnome-robots 50.0.0 game/PlayerCommand#SW#), |
| 376 | (NO_MODrust-analyzer cargo gnome-robots 50.0.0 game_area/NO_MOD., gdkrust-analyzer cargo gdk4 0.11.1 crate/::Keyrust-analyzer cargo gdk4 0.11.1 keys/Key#::KP_2rust-analyzer cargo gdk4 0.11.1 keys/impl#[Key]KP_2. | gdkrust-analyzer cargo gdk4 0.11.1 crate/::Keyrust-analyzer cargo gdk4 0.11.1 keys/Key#::KP_Downrust-analyzer cargo gdk4 0.11.1 keys/impl#[Key]KP_Down.) => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(PlayerCommandrust-analyzer cargo gnome-robots 50.0.0 game/PlayerCommand#::Srust-analyzer cargo gnome-robots 50.0.0 game/PlayerCommand#S#), |
| 377 | (NO_MODrust-analyzer cargo gnome-robots 50.0.0 game_area/NO_MOD., gdkrust-analyzer cargo gdk4 0.11.1 crate/::Keyrust-analyzer cargo gdk4 0.11.1 keys/Key#::KP_3rust-analyzer cargo gdk4 0.11.1 keys/impl#[Key]KP_3. | gdkrust-analyzer cargo gdk4 0.11.1 crate/::Keyrust-analyzer cargo gdk4 0.11.1 keys/Key#::KP_Page_Downrust-analyzer cargo gdk4 0.11.1 keys/impl#[Key]KP_Page_Down.) => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(PlayerCommandrust-analyzer cargo gnome-robots 50.0.0 game/PlayerCommand#::SErust-analyzer cargo gnome-robots 50.0.0 game/PlayerCommand#SE#), |
| 378 | (NO_MODrust-analyzer cargo gnome-robots 50.0.0 game_area/NO_MOD., gdkrust-analyzer cargo gdk4 0.11.1 crate/::Keyrust-analyzer cargo gdk4 0.11.1 keys/Key#::KP_4rust-analyzer cargo gdk4 0.11.1 keys/impl#[Key]KP_4. | gdkrust-analyzer cargo gdk4 0.11.1 crate/::Keyrust-analyzer cargo gdk4 0.11.1 keys/Key#::KP_Leftrust-analyzer cargo gdk4 0.11.1 keys/impl#[Key]KP_Left.) => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(PlayerCommandrust-analyzer cargo gnome-robots 50.0.0 game/PlayerCommand#::Wrust-analyzer cargo gnome-robots 50.0.0 game/PlayerCommand#W#), |
| 379 | (NO_MODrust-analyzer cargo gnome-robots 50.0.0 game_area/NO_MOD., gdkrust-analyzer cargo gdk4 0.11.1 crate/::Keyrust-analyzer cargo gdk4 0.11.1 keys/Key#::KP_5rust-analyzer cargo gdk4 0.11.1 keys/impl#[Key]KP_5. | gdkrust-analyzer cargo gdk4 0.11.1 crate/::Keyrust-analyzer cargo gdk4 0.11.1 keys/Key#::KP_Beginrust-analyzer cargo gdk4 0.11.1 keys/impl#[Key]KP_Begin.) => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(PlayerCommandrust-analyzer cargo gnome-robots 50.0.0 game/PlayerCommand#::Stayrust-analyzer cargo gnome-robots 50.0.0 game/PlayerCommand#Stay#), |
| 380 | (CTRLrust-analyzer cargo gnome-robots 50.0.0 game_area/CTRL., gdkrust-analyzer cargo gdk4 0.11.1 crate/::Keyrust-analyzer cargo gdk4 0.11.1 keys/Key#::KP_5rust-analyzer cargo gdk4 0.11.1 keys/impl#[Key]KP_5. | gdkrust-analyzer cargo gdk4 0.11.1 crate/::Keyrust-analyzer cargo gdk4 0.11.1 keys/Key#::KP_Beginrust-analyzer cargo gdk4 0.11.1 keys/impl#[Key]KP_Begin.) => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(PlayerCommandrust-analyzer cargo gnome-robots 50.0.0 game/PlayerCommand#::Waitrust-analyzer cargo gnome-robots 50.0.0 game/PlayerCommand#Wait#), |
| 381 | (NO_MODrust-analyzer cargo gnome-robots 50.0.0 game_area/NO_MOD., gdkrust-analyzer cargo gdk4 0.11.1 crate/::Keyrust-analyzer cargo gdk4 0.11.1 keys/Key#::KP_6rust-analyzer cargo gdk4 0.11.1 keys/impl#[Key]KP_6. | gdkrust-analyzer cargo gdk4 0.11.1 crate/::Keyrust-analyzer cargo gdk4 0.11.1 keys/Key#::KP_Rightrust-analyzer cargo gdk4 0.11.1 keys/impl#[Key]KP_Right.) => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(PlayerCommandrust-analyzer cargo gnome-robots 50.0.0 game/PlayerCommand#::Erust-analyzer cargo gnome-robots 50.0.0 game/PlayerCommand#E#), |
| 382 | (NO_MODrust-analyzer cargo gnome-robots 50.0.0 game_area/NO_MOD., gdkrust-analyzer cargo gdk4 0.11.1 crate/::Keyrust-analyzer cargo gdk4 0.11.1 keys/Key#::KP_7rust-analyzer cargo gdk4 0.11.1 keys/impl#[Key]KP_7. | gdkrust-analyzer cargo gdk4 0.11.1 crate/::Keyrust-analyzer cargo gdk4 0.11.1 keys/Key#::KP_Homerust-analyzer cargo gdk4 0.11.1 keys/impl#[Key]KP_Home.) => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(PlayerCommandrust-analyzer cargo gnome-robots 50.0.0 game/PlayerCommand#::NWrust-analyzer cargo gnome-robots 50.0.0 game/PlayerCommand#NW#), |
| 383 | (NO_MODrust-analyzer cargo gnome-robots 50.0.0 game_area/NO_MOD., gdkrust-analyzer cargo gdk4 0.11.1 crate/::Keyrust-analyzer cargo gdk4 0.11.1 keys/Key#::KP_8rust-analyzer cargo gdk4 0.11.1 keys/impl#[Key]KP_8. | gdkrust-analyzer cargo gdk4 0.11.1 crate/::Keyrust-analyzer cargo gdk4 0.11.1 keys/Key#::KP_Uprust-analyzer cargo gdk4 0.11.1 keys/impl#[Key]KP_Up.) => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(PlayerCommandrust-analyzer cargo gnome-robots 50.0.0 game/PlayerCommand#::Nrust-analyzer cargo gnome-robots 50.0.0 game/PlayerCommand#N#), |
| 384 | (NO_MODrust-analyzer cargo gnome-robots 50.0.0 game_area/NO_MOD., gdkrust-analyzer cargo gdk4 0.11.1 crate/::Keyrust-analyzer cargo gdk4 0.11.1 keys/Key#::KP_9rust-analyzer cargo gdk4 0.11.1 keys/impl#[Key]KP_9. | gdkrust-analyzer cargo gdk4 0.11.1 crate/::Keyrust-analyzer cargo gdk4 0.11.1 keys/Key#::KP_Page_Uprust-analyzer cargo gdk4 0.11.1 keys/impl#[Key]KP_Page_Up.) => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(PlayerCommandrust-analyzer cargo gnome-robots 50.0.0 game/PlayerCommand#::NErust-analyzer cargo gnome-robots 50.0.0 game/PlayerCommand#NE#), |
| 385 | (NO_MODrust-analyzer cargo gnome-robots 50.0.0 game_area/NO_MOD., key) => { |
| 386 | let settings = self.imprust-analyzer cargo glib 0.22.3 subclass/types/impl#[T][ObjectSubclassIsExt]imp().().settingsrust-analyzer cargo gnome-robots 50.0.0 game_area/imp/GameArea#settings..getrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/once/impl#[`OnceCell<T>`]get().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(); |
| 387 | CONTROL_KEYSrust-analyzer cargo gnome-robots 50.0.0 properties/CONTROL_KEYS. |
| 388 | .iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().() |
| 389 | .find_maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/iter/impl#[`Iter<'a, T>`][Iterator]find_map().(|ck| (settings.get_control_keyrust-analyzer cargo gnome-robots 50.0.0 properties/impl#[`gio::Settings`][Properties]get_control_key().(ck) rust-analyzer cargo gdk4 0.11.1 keys/impl#[Key][`PartialEq<Self>`]eq().==rust-analyzer cargo gdk4 0.11.1 keys/impl#[Key][`PartialEq<Self>`]eq(). rust-analyzer cargo gdk4 0.11.1 keys/impl#[Key][`PartialEq<Self>`]eq().key).then_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core bool/impl#[bool]then_some().(ck.commandrust-analyzer cargo gnome-robots 50.0.0 properties/ControlKey#command.)) |
| 390 | } |
| 391 | _ => Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 392 | }; |
| 393 | |
| 394 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(command) = command { |
| 395 | self.player_commandrust-analyzer cargo gnome-robots 50.0.0 game_area/impl#[GameArea]player_command().(command); |
| 396 | glibrust-analyzer cargo glib 0.22.3 crate/::Propagationrust-analyzer cargo glib 0.22.3 signal/Propagation#::Stoprust-analyzer cargo glib 0.22.3 signal/Propagation#Stop# |
| 397 | } else { |
| 398 | glibrust-analyzer cargo glib 0.22.3 crate/::Propagationrust-analyzer cargo glib 0.22.3 signal/Propagation#::Proceedrust-analyzer cargo glib 0.22.3 signal/Propagation#Proceed# |
| 399 | } |
| 400 | } |
| 401 | |
| 402 | fn get_dirrust-analyzer cargo gnome-robots 50.0.0 game_area/impl#[GameArea]get_dir().(&self, game: &Gamerust-analyzer cargo gnome-robots 50.0.0 game/Game#, ix: f64, iy: f64) -> (i32, i32) { |
| 403 | let tile_width = (self.widthrust-analyzer cargo gtk4 0.11.1 auto/widget/WidgetExt#width().() as f64) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div().(game.widthrust-analyzer cargo gnome-robots 50.0.0 game/impl#[Game]width().() as f64); |
| 404 | let tile_height = (self.heightrust-analyzer cargo gtk4 0.11.1 auto/widget/WidgetExt#height().() as f64) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div().(game.heightrust-analyzer cargo gnome-robots 50.0.0 game/impl#[Game]height().() as f64); |
| 405 | |
| 406 | let x = ((ix rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div().tile_width) as u32).clamprust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][Ord]clamp().(0, game.widthrust-analyzer cargo gnome-robots 50.0.0 game/impl#[Game]width().()); |
| 407 | let y = ((iy rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div().tile_height) as u32).clamprust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][Ord]clamp().(0, game.heightrust-analyzer cargo gnome-robots 50.0.0 game/impl#[Game]height().()); |
| 408 | |
| 409 | let player = game.playerrust-analyzer cargo gnome-robots 50.0.0 game/impl#[Game]player().(); |
| 410 | |
| 411 | // If we click on our man then we assume we hold. |
| 412 | if x rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialEq<Self>`]eq().player.xrust-analyzer cargo gnome-robots 50.0.0 arena/Position#x. && y rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialEq<Self>`]eq().player.yrust-analyzer cargo gnome-robots 50.0.0 arena/Position#y. { |
| 413 | return (0, 0); |
| 414 | } |
| 415 | |
| 416 | // go in the general direction of the mouse click. |
| 417 | let dx = ix rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div().tile_width rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Sub<Self>`]sub().(player.xrust-analyzer cargo gnome-robots 50.0.0 arena/Position#x. as f64 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Add<Self>`]add().0.5); |
| 418 | let dy = iy rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div().tile_height rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Sub<Self>`]sub().(player.yrust-analyzer cargo gnome-robots 50.0.0 arena/Position#y. as f64 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Add<Self>`]add().0.5); |
| 419 | |
| 420 | round_directionrust-analyzer cargo gnome-robots 50.0.0 game_area/round_direction().(dx, dy) |
| 421 | } |
| 422 | |
| 423 | fn properties_changed_cbrust-analyzer cargo gnome-robots 50.0.0 game_area/impl#[GameArea]properties_changed_cb().(&self, settings: &giorust-analyzer cargo gio 0.22.2 crate/::Settingsrust-analyzer cargo gio 0.22.2 auto/settings/Settings#) { |
| 424 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(game) = self.imprust-analyzer cargo glib 0.22.3 subclass/types/impl#[T][ObjectSubclassIsExt]imp().().gamerust-analyzer cargo gnome-robots 50.0.0 game_area/imp/GameArea#game..borrowrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/impl#[`RefCell<T>`]borrow().().as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_ref().() { |
| 425 | let selected_config = settings.selected_configrust-analyzer cargo gnome-robots 50.0.0 properties/impl#[`gio::Settings`][Properties]selected_config().(); |
| 426 | match self |
| 427 | .imprust-analyzer cargo glib 0.22.3 subclass/types/impl#[T][ObjectSubclassIsExt]imp().() |
| 428 | .game_configsrust-analyzer cargo gnome-robots 50.0.0 game_area/imp/GameArea#game_configs. |
| 429 | .getrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/once/impl#[`OnceCell<T>`]get().() |
| 430 | .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().() |
| 431 | .find_by_namerust-analyzer cargo gnome-robots 50.0.0 game_config/impl#[GameConfigs]find_by_name().(&selected_config) |
| 432 | { |
| 433 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(config) => { |
| 434 | game.set_configrust-analyzer cargo gnome-robots 50.0.0 game/impl#[Game]set_config().(config); |
| 435 | } |
| 436 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => { |
| 437 | eprintlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/eprintln!!("Cannot change config to {}", selected_config); |
| 438 | } |
| 439 | } |
| 440 | } |
| 441 | |
| 442 | let selected_theme = settings.themerust-analyzer cargo gnome-robots 50.0.0 properties/impl#[`gio::Settings`][Properties]theme().(); |
| 443 | match themesrust-analyzer cargo gnome-robots 50.0.0 themes/::find_best_matchrust-analyzer cargo gnome-robots 50.0.0 themes/find_best_match().(&self.imprust-analyzer cargo glib 0.22.3 subclass/types/impl#[T][ObjectSubclassIsExt]imp().().assetsrust-analyzer cargo gnome-robots 50.0.0 game_area/imp/GameArea#assets..getrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/once/impl#[`OnceCell<T>`]get().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().themesrust-analyzer cargo gnome-robots 50.0.0 assets/Assets#themes().(), &selected_theme) { |
| 444 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(theme) => { |
| 445 | *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/impl#[`RefMut<'_, T>`][DerefMut]deref_mut().self.imprust-analyzer cargo glib 0.22.3 subclass/types/impl#[T][ObjectSubclassIsExt]imp().().themerust-analyzer cargo gnome-robots 50.0.0 game_area/imp/GameArea#theme..borrow_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/impl#[`RefCell<T>`]borrow_mut().() = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(theme); |
| 446 | } |
| 447 | Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(error) => { |
| 448 | eprintlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/eprintln!!("Cannot change theme to {}: {}", selected_theme, error); |
| 449 | } |
| 450 | } |
| 451 | |
| 452 | self.set_background_colorrust-analyzer cargo gnome-robots 50.0.0 game_area/impl#[GameArea]set_background_color().(settings.bgcolourrust-analyzer cargo gnome-robots 50.0.0 properties/impl#[`gio::Settings`][Properties]bgcolour().()); |
| 453 | |
| 454 | self.queue_drawrust-analyzer cargo gtk4 0.11.1 auto/widget/WidgetExt#queue_draw().(); |
| 455 | } |
| 456 | |
| 457 | pub fn start_new_gamerust-analyzer cargo gnome-robots 50.0.0 game_area/impl#[GameArea]start_new_game().(&self) { |
| 458 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(game) = self.imprust-analyzer cargo glib 0.22.3 subclass/types/impl#[T][ObjectSubclassIsExt]imp().().gamerust-analyzer cargo gnome-robots 50.0.0 game_area/imp/GameArea#game..borrowrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/impl#[`RefCell<T>`]borrow().().as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_ref().() { |
| 459 | game.start_new_gamerust-analyzer cargo gnome-robots 50.0.0 game/impl#[Game]start_new_game().(); |
| 460 | self.queue_drawrust-analyzer cargo gtk4 0.11.1 auto/widget/WidgetExt#queue_draw().(); |
| 461 | } |
| 462 | } |
| 463 | |
| 464 | pub fn player_commandrust-analyzer cargo gnome-robots 50.0.0 game_area/impl#[GameArea]player_command().(&self, cmd: PlayerCommandrust-analyzer cargo gnome-robots 50.0.0 game/PlayerCommand#) { |
| 465 | let game_ref = self.imprust-analyzer cargo glib 0.22.3 subclass/types/impl#[T][ObjectSubclassIsExt]imp().().gamerust-analyzer cargo gnome-robots 50.0.0 game_area/imp/GameArea#game..borrowrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/impl#[`RefCell<T>`]borrow().(); |
| 466 | let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(game) = game_ref.as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_ref().() else { |
| 467 | return; |
| 468 | }; |
| 469 | let safety = self.move_safetyrust-analyzer cargo gnome-robots 50.0.0 game_area/impl#[GameArea]move_safety().(); |
| 470 | if game.player_commandrust-analyzer cargo gnome-robots 50.0.0 game/impl#[Game]player_command().(cmd, safety) { |
| 471 | self.queue_drawrust-analyzer cargo gtk4 0.11.1 auto/widget/WidgetExt#queue_draw().(); |
| 472 | } else { |
| 473 | self.play_soundrust-analyzer cargo gnome-robots 50.0.0 game_area/impl#[GameArea]play_sound().(Soundrust-analyzer cargo gnome-robots 50.0.0 sound_player/Sound#::Badrust-analyzer cargo gnome-robots 50.0.0 sound_player/Sound#Bad#); |
| 474 | } |
| 475 | } |
| 476 | |
| 477 | async fn on_game_eventrust-analyzer cargo gnome-robots 50.0.0 game_area/impl#[GameArea]on_game_event().(&self, event: GameEventrust-analyzer cargo gnome-robots 50.0.0 game/GameEvent#) { |
| 478 | match event { |
| 479 | GameEventrust-analyzer cargo gnome-robots 50.0.0 game/GameEvent#::Teleportedrust-analyzer cargo gnome-robots 50.0.0 game/GameEvent#Teleported# => self.play_soundrust-analyzer cargo gnome-robots 50.0.0 game_area/impl#[GameArea]play_sound().(Soundrust-analyzer cargo gnome-robots 50.0.0 sound_player/Sound#::Teleportrust-analyzer cargo gnome-robots 50.0.0 sound_player/Sound#Teleport#), |
| 480 | GameEventrust-analyzer cargo gnome-robots 50.0.0 game/GameEvent#::Splatrust-analyzer cargo gnome-robots 50.0.0 game/GameEvent#Splat# => self.play_soundrust-analyzer cargo gnome-robots 50.0.0 game_area/impl#[GameArea]play_sound().(Soundrust-analyzer cargo gnome-robots 50.0.0 sound_player/Sound#::Splatrust-analyzer cargo gnome-robots 50.0.0 sound_player/Sound#Splat#), |
| 481 | GameEventrust-analyzer cargo gnome-robots 50.0.0 game/GameEvent#::LevelCompleterust-analyzer cargo gnome-robots 50.0.0 game/GameEvent#LevelComplete# => self.play_soundrust-analyzer cargo gnome-robots 50.0.0 game_area/impl#[GameArea]play_sound().(Soundrust-analyzer cargo gnome-robots 50.0.0 sound_player/Sound#::Yahoorust-analyzer cargo gnome-robots 50.0.0 sound_player/Sound#Yahoo#), |
| 482 | GameEventrust-analyzer cargo gnome-robots 50.0.0 game/GameEvent#::Deathrust-analyzer cargo gnome-robots 50.0.0 game/GameEvent#Death# => self.play_soundrust-analyzer cargo gnome-robots 50.0.0 game_area/impl#[GameArea]play_sound().(Soundrust-analyzer cargo gnome-robots 50.0.0 sound_player/Sound#::Dierust-analyzer cargo gnome-robots 50.0.0 sound_player/Sound#Die#), |
| 483 | GameEventrust-analyzer cargo gnome-robots 50.0.0 game/GameEvent#::Scoredrust-analyzer cargo gnome-robots 50.0.0 game/GameEvent#Scored#(score) if score rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialOrd<Self>`]gt().0 => self.log_scorerust-analyzer cargo gnome-robots 50.0.0 game_area/impl#[GameArea]log_score().(score).rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll()., |
| 484 | GameEventrust-analyzer cargo gnome-robots 50.0.0 game/GameEvent#::Victoryrust-analyzer cargo gnome-robots 50.0.0 game/GameEvent#Victory# => { |
| 485 | self.message_boxrust-analyzer cargo gnome-robots 50.0.0 game_area/impl#[GameArea]message_box().(&gettextrust-analyzer cargo gettext-rs 0.7.7 gettext().( |
| 486 | "Congratulations, You Have Defeated the Robots!! \nBut Can You do it Again?", |
| 487 | )); |
| 488 | self.play_soundrust-analyzer cargo gnome-robots 50.0.0 game_area/impl#[GameArea]play_sound().(Soundrust-analyzer cargo gnome-robots 50.0.0 sound_player/Sound#::Victoryrust-analyzer cargo gnome-robots 50.0.0 sound_player/Sound#Victory#); |
| 489 | } |
| 490 | GameEventrust-analyzer cargo gnome-robots 50.0.0 game/GameEvent#::NoTeleportLocationsrust-analyzer cargo gnome-robots 50.0.0 game/GameEvent#NoTeleportLocations# => { |
| 491 | self.message_boxrust-analyzer cargo gnome-robots 50.0.0 game_area/impl#[GameArea]message_box().(&gettextrust-analyzer cargo gettext-rs 0.7.7 gettext().("There are no teleport locations left!!")); |
| 492 | } |
| 493 | _ => {} |
| 494 | } |
| 495 | } |
| 496 | |
| 497 | fn move_safetyrust-analyzer cargo gnome-robots 50.0.0 game_area/impl#[GameArea]move_safety().(&self) -> MoveSafetyrust-analyzer cargo gnome-robots 50.0.0 game/MoveSafety# { |
| 498 | let properties = self.imprust-analyzer cargo glib 0.22.3 subclass/types/impl#[T][ObjectSubclassIsExt]imp().().settingsrust-analyzer cargo gnome-robots 50.0.0 game_area/imp/GameArea#settings..getrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/once/impl#[`OnceCell<T>`]get().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(); |
| 499 | properties.move_safetyrust-analyzer cargo gnome-robots 50.0.0 properties/Properties#move_safety().() |
| 500 | } |
| 501 | |
| 502 | fn game_configrust-analyzer cargo gnome-robots 50.0.0 game_area/impl#[GameArea]game_config().(&self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Rcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc rc/Rc#<GameConfigrust-analyzer cargo gnome-robots 50.0.0 game_config/GameConfig#>> { |
| 503 | self.imprust-analyzer cargo glib 0.22.3 subclass/types/impl#[T][ObjectSubclassIsExt]imp().().gamerust-analyzer cargo gnome-robots 50.0.0 game_area/imp/GameArea#game..borrowrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/impl#[`RefCell<T>`]borrow().().as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_ref().().maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|g| g.configrust-analyzer cargo gnome-robots 50.0.0 game/impl#[Game]config().()) |
| 504 | } |
| 505 | |
| 506 | /// Enters a score in the high-score table |
| 507 | async fn log_scorerust-analyzer cargo gnome-robots 50.0.0 game_area/impl#[GameArea]log_score().(&self, score: u32) { |
| 508 | let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(game_config) = self.game_configrust-analyzer cargo gnome-robots 50.0.0 game_area/impl#[GameArea]game_config().() else { |
| 509 | return; |
| 510 | }; |
| 511 | let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(window) = self.rootrust-analyzer cargo gtk4 0.11.1 auto/widget/WidgetExt#root().().and_downcastrust-analyzer cargo glib 0.22.3 object/impl#[`Option<I>`][CastNone]and_downcast().::<gtkrust-analyzer cargo gtk4 0.11.1 crate/::Windowrust-analyzer cargo gtk4 0.11.1 auto/window/Window#>() else { |
| 512 | return; |
| 513 | }; |
| 514 | |
| 515 | let category = Categoryrust-analyzer cargo gnome-robots 50.0.0 scores/scores/Category# { |
| 516 | keyrust-analyzer cargo gnome-robots 50.0.0 scores/scores/Category#key.: game_config.namerust-analyzer cargo gnome-robots 50.0.0 game_config/GameConfig#name..to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), |
| 517 | safetyrust-analyzer cargo gnome-robots 50.0.0 scores/scores/Category#safety.: self.move_safetyrust-analyzer cargo gnome-robots 50.0.0 game_area/impl#[GameArea]move_safety().(), |
| 518 | }; |
| 519 | add_scorerust-analyzer cargo gnome-robots 50.0.0 scores/scores/add_score().(&category, score as i64, &window).rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().; |
| 520 | } |
| 521 | |
| 522 | fn play_soundrust-analyzer cargo gnome-robots 50.0.0 game_area/impl#[GameArea]play_sound().(&self, sound: Soundrust-analyzer cargo gnome-robots 50.0.0 sound_player/Sound#) { |
| 523 | let properties = self.imprust-analyzer cargo glib 0.22.3 subclass/types/impl#[T][ObjectSubclassIsExt]imp().().settingsrust-analyzer cargo gnome-robots 50.0.0 game_area/imp/GameArea#settings..getrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/once/impl#[`OnceCell<T>`]get().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(); |
| 524 | if properties.soundrust-analyzer cargo gnome-robots 50.0.0 properties/impl#[`gio::Settings`][Properties]sound().() { |
| 525 | self.imprust-analyzer cargo glib 0.22.3 subclass/types/impl#[T][ObjectSubclassIsExt]imp().().sound_playerrust-analyzer cargo gnome-robots 50.0.0 game_area/imp/GameArea#sound_player..playrust-analyzer cargo gnome-robots 50.0.0 sound_player/impl#[SoundPlayer]play().(sound); |
| 526 | } |
| 527 | } |
| 528 | |
| 529 | /// Displays a modal dialog box with a given message |
| 530 | fn message_boxrust-analyzer cargo gnome-robots 50.0.0 game_area/impl#[GameArea]message_box().(&self, msg: &str) { |
| 531 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(window) = self.rootrust-analyzer cargo gtk4 0.11.1 auto/widget/WidgetExt#root().().and_downcastrust-analyzer cargo glib 0.22.3 object/impl#[`Option<I>`][CastNone]and_downcast().::<gtkrust-analyzer cargo gtk4 0.11.1 crate/::Windowrust-analyzer cargo gtk4 0.11.1 auto/window/Window#>() { |
| 532 | let dialog = gtkrust-analyzer cargo gtk4 0.11.1 crate/::AlertDialogrust-analyzer cargo gtk4 0.11.1 auto/alert_dialog/AlertDialog#::builderrust-analyzer cargo gtk4 0.11.1 auto/alert_dialog/impl#[AlertDialog]builder().().messagerust-analyzer cargo gtk4 0.11.1 auto/alert_dialog/impl#[AlertDialogBuilder]message().(msg).modalrust-analyzer cargo gtk4 0.11.1 auto/alert_dialog/impl#[AlertDialogBuilder]modal().(true).buildrust-analyzer cargo gtk4 0.11.1 auto/alert_dialog/impl#[AlertDialogBuilder]build().(); |
| 533 | dialog.showrust-analyzer cargo gtk4 0.11.1 auto/alert_dialog/impl#[AlertDialog]show().(Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(&window)); |
| 534 | } else { |
| 535 | eprintlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/eprintln!!("There is no top level window."); |
| 536 | printlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/println!!("{}", msg); |
| 537 | } |
| 538 | } |
| 539 | |
| 540 | pub fn connect_updatedrust-analyzer cargo gnome-robots 50.0.0 game_area/impl#[GameArea]connect_updated().<F>(&self, f: F) -> glibrust-analyzer cargo glib 0.22.3 crate/::signalrust-analyzer cargo glib 0.22.3 signal/::SignalHandlerIdrust-analyzer cargo glib 0.22.3 signal/SignalHandlerId# |
| 541 | where |
| 542 | F: Fnrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/function/Fn#(&Selfrust-analyzer cargo gnome-robots 50.0.0 game_area/impl#[GameArea]) + 'static, |
| 543 | { |
| 544 | self.connect_closurerust-analyzer cargo glib 0.22.3 object/impl#[T][ObjectExt]connect_closure().( |
| 545 | "updated", |
| 546 | false, |
| 547 | glibrust-analyzer cargo glib 0.22.3 crate/::closure_localrust-analyzer cargo glib-macros 0.22.2 closure_local!!(move |this: &Selfrust-analyzer cargo gnome-robots 50.0.0 game_area/impl#[GameArea]| (f)(this)), |
| 548 | ) |
| 549 | } |
| 550 | } |
| 551 | |
| 552 | fn round_directionrust-analyzer cargo gnome-robots 50.0.0 game_area/round_direction().(dx: f64, dy: f64) -> (i32, i32) { |
| 553 | if dx.absrust-analyzer cargo core https://github.com/rust-lang/rust/library/core f64/impl#[f64]abs().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[f64][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[f64][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[f64][`PartialOrd<Self>`]lt().0.5 && dy.absrust-analyzer cargo core https://github.com/rust-lang/rust/library/core f64/impl#[f64]abs().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[f64][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[f64][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[f64][`PartialOrd<Self>`]lt().0.5 { |
| 554 | return (0, 0); |
| 555 | } |
| 556 | |
| 557 | const MOVE_TABLErust-analyzer cargo gnome-robots 50.0.0 game_area/MOVE_TABLE.: [(i32, i32); 8] = [ |
| 558 | (-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][Neg]neg().1, 0), |
| 559 | (-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][Neg]neg().1, -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][Neg]neg().1), |
| 560 | (0, -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][Neg]neg().1), |
| 561 | (1, -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][Neg]neg().1), |
| 562 | (1, 0), |
| 563 | (1, 1), |
| 564 | (0, 1), |
| 565 | (-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][Neg]neg().1, 1), |
| 566 | ]; |
| 567 | |
| 568 | let angle = f64::atan2rust-analyzer cargo std https://github.com/rust-lang/rust/library/std f64/impl#[f64]atan2().(dy, dx); |
| 569 | |
| 570 | /* Note the adjustment we have to make (+9, not +8) because atan2's idea |
| 571 | * of octants and the ones we want are shifted by PI/8. */ |
| 572 | let octant = (((8.0 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul().angle rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div().PIrust-analyzer cargo core https://github.com/rust-lang/rust/library/core f64/consts/PI.).floorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std f64/impl#[f64]floor().() as i32 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Add<Self>`]add().9) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Div<Self>`]div().2) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Rem<Self>`]rem().%rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Rem<Self>`]rem(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Rem<Self>`]rem().8; |
| 573 | |
| 574 | MOVE_TABLErust-analyzer cargo gnome-robots 50.0.0 game_area/MOVE_TABLE.[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().octant as usize]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index(). |
| 575 | } |
| 576 | |
| 577 | #[cfg(test)] |
| 578 | mod testrust-analyzer cargo gnome-robots 50.0.0 game_area/test/ { |
| 579 | use superrust-analyzer cargo gnome-robots 50.0.0 game_area/::*; |
| 580 | |
| 581 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 582 | fn test_round_directionrust-analyzer cargo gnome-robots 50.0.0 game_area/test/test_round_direction().() { |
| 583 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(round_directionrust-analyzer cargo gnome-robots 50.0.0 game_area/round_direction().(-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][Neg]neg().2.0, -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][Neg]neg().3.0), (-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][Neg]neg().1, -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][Neg]neg().1)); |
| 584 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(round_directionrust-analyzer cargo gnome-robots 50.0.0 game_area/round_direction().(-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][Neg]neg().3.0, -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][Neg]neg().3.0), (-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][Neg]neg().1, -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][Neg]neg().1)); |
| 585 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(round_directionrust-analyzer cargo gnome-robots 50.0.0 game_area/round_direction().(-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][Neg]neg().3.0, -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][Neg]neg().1.0), (-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][Neg]neg().1, 0)); |
| 586 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(round_directionrust-analyzer cargo gnome-robots 50.0.0 game_area/round_direction().(-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][Neg]neg().3.0, 0.0), (-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][Neg]neg().1, 0)); |
| 587 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(round_directionrust-analyzer cargo gnome-robots 50.0.0 game_area/round_direction().(-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][Neg]neg().3.0, 1.0), (-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][Neg]neg().1, 0)); |
| 588 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(round_directionrust-analyzer cargo gnome-robots 50.0.0 game_area/round_direction().(-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][Neg]neg().3.0, 3.0), (-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][Neg]neg().1, 1)); |
| 589 | |
| 590 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(round_directionrust-analyzer cargo gnome-robots 50.0.0 game_area/round_direction().(-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][Neg]neg().1.0, -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][Neg]neg().3.0), (0, -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][Neg]neg().1)); |
| 591 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(round_directionrust-analyzer cargo gnome-robots 50.0.0 game_area/round_direction().(-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][Neg]neg().1.0, -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][Neg]neg().1.0), (-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][Neg]neg().1, -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][Neg]neg().1)); |
| 592 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(round_directionrust-analyzer cargo gnome-robots 50.0.0 game_area/round_direction().(-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][Neg]neg().1.0, 0.0), (-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][Neg]neg().1, 0)); |
| 593 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(round_directionrust-analyzer cargo gnome-robots 50.0.0 game_area/round_direction().(-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][Neg]neg().1.0, 1.0), (-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][Neg]neg().1, 1)); |
| 594 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(round_directionrust-analyzer cargo gnome-robots 50.0.0 game_area/round_direction().(-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][Neg]neg().1.0, 3.0), (0, 1)); |
| 595 | |
| 596 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(round_directionrust-analyzer cargo gnome-robots 50.0.0 game_area/round_direction().(0.0, -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][Neg]neg().2.0), (0, -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][Neg]neg().1)); |
| 597 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(round_directionrust-analyzer cargo gnome-robots 50.0.0 game_area/round_direction().(0.0, -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][Neg]neg().1.0), (0, -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][Neg]neg().1)); |
| 598 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(round_directionrust-analyzer cargo gnome-robots 50.0.0 game_area/round_direction().(0.0, 0.0), (0, 0)); |
| 599 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(round_directionrust-analyzer cargo gnome-robots 50.0.0 game_area/round_direction().(0.0, 1.0), (0, 1)); |
| 600 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(round_directionrust-analyzer cargo gnome-robots 50.0.0 game_area/round_direction().(0.0, 2.0), (0, 1)); |
| 601 | |
| 602 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(round_directionrust-analyzer cargo gnome-robots 50.0.0 game_area/round_direction().(1.0, -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][Neg]neg().2.0), (1, -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][Neg]neg().1)); |
| 603 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(round_directionrust-analyzer cargo gnome-robots 50.0.0 game_area/round_direction().(1.0, -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][Neg]neg().1.0), (1, -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][Neg]neg().1)); |
| 604 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(round_directionrust-analyzer cargo gnome-robots 50.0.0 game_area/round_direction().(1.0, 0.0), (1, 0)); |
| 605 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(round_directionrust-analyzer cargo gnome-robots 50.0.0 game_area/round_direction().(1.0, 1.0), (1, 1)); |
| 606 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(round_directionrust-analyzer cargo gnome-robots 50.0.0 game_area/round_direction().(1.0, 2.0), (1, 1)); |
| 607 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(round_directionrust-analyzer cargo gnome-robots 50.0.0 game_area/round_direction().(1.0, 3.0), (0, 1)); |
| 608 | |
| 609 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(round_directionrust-analyzer cargo gnome-robots 50.0.0 game_area/round_direction().(2.0, -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][Neg]neg().2.0), (1, -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][Neg]neg().1)); |
| 610 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(round_directionrust-analyzer cargo gnome-robots 50.0.0 game_area/round_direction().(2.0, -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][Neg]neg().1.0), (1, -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][Neg]neg().1)); |
| 611 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(round_directionrust-analyzer cargo gnome-robots 50.0.0 game_area/round_direction().(2.0, 0.0), (1, 0)); |
| 612 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(round_directionrust-analyzer cargo gnome-robots 50.0.0 game_area/round_direction().(2.0, 1.0), (1, 1)); |
| 613 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(round_directionrust-analyzer cargo gnome-robots 50.0.0 game_area/round_direction().(2.0, 2.0), (1, 1)); |
| 614 | } |
| 615 | } |