Use Rc instead of Arc for fonts
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
use std::{
|
||||
collections::HashMap,
|
||||
fmt::{self, Display, Formatter},
|
||||
sync::Arc,
|
||||
rc::Rc,
|
||||
};
|
||||
|
||||
mod button;
|
||||
@@ -28,7 +28,7 @@ pub struct Game {
|
||||
// Constants througout the game
|
||||
texture_res: Texture2D,
|
||||
sounds: Sounds,
|
||||
font: Arc<Font>,
|
||||
font: Rc<Font>,
|
||||
num_squares: usize,
|
||||
heading_text: String,
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use std::sync::Arc;
|
||||
use std::rc::Rc;
|
||||
|
||||
use macroquad::{audio::Sound, prelude::*};
|
||||
|
||||
@@ -15,11 +15,11 @@ pub struct Button {
|
||||
shadow_width: f32,
|
||||
pub color: UiColor,
|
||||
sound: Sound,
|
||||
font: Arc<Font>,
|
||||
font: Rc<Font>,
|
||||
}
|
||||
|
||||
impl Button {
|
||||
pub fn new(text: &str, rect: Rect, color: UiColor, sound: Sound, font: Arc<Font>) -> Self {
|
||||
pub fn new(text: &str, rect: Rect, color: UiColor, sound: Sound, font: Rc<Font>) -> Self {
|
||||
Self {
|
||||
text: text.to_string(),
|
||||
is_down: false,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use std::{collections::HashMap, sync::Arc};
|
||||
use std::{collections::HashMap, rc::Rc};
|
||||
|
||||
use super::{
|
||||
constants, sound::Sounds, Board, BoardState, ButtonAction, Game, GameMode, GameSquare,
|
||||
@@ -6,7 +6,10 @@ use super::{
|
||||
};
|
||||
|
||||
use macroquad::prelude::*;
|
||||
use sol_chess::{board, generator::{self, RandomRange}};
|
||||
use sol_chess::{
|
||||
board,
|
||||
generator::{self, RandomRange},
|
||||
};
|
||||
|
||||
impl Game {
|
||||
fn get(&mut self, i: usize, j: usize) -> &mut GameSquare {
|
||||
@@ -299,7 +302,7 @@ impl Game {
|
||||
window_height: 0.,
|
||||
window_width: 0.,
|
||||
square_width: 0.,
|
||||
font: Arc::new(font),
|
||||
font: Rc::new(font),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
-8
@@ -30,15 +30,9 @@ pub(crate) fn b64_decode_48(input: &[u8; 8], output: &mut [u8; 6]) {
|
||||
const ALPHABET: &str = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
|
||||
|
||||
fn lookup(idx: u8) -> char {
|
||||
ALPHABET
|
||||
.chars()
|
||||
.nth(idx as usize)
|
||||
.unwrap()
|
||||
ALPHABET.chars().nth(idx as usize).unwrap()
|
||||
}
|
||||
|
||||
fn reverse_lookup(c: char) -> u8 {
|
||||
ALPHABET
|
||||
.chars()
|
||||
.position(|x| x == c)
|
||||
.unwrap() as u8
|
||||
ALPHABET.chars().position(|x| x == c).unwrap() as u8
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user