Skip to content

Commit

Permalink
langauge display text size
Browse files Browse the repository at this point in the history
  • Loading branch information
eguneys committed Dec 11, 2022
1 parent 351e7c6 commit fa98213
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 197 deletions.
217 changes: 28 additions & 189 deletions src/game.ts
Original file line number Diff line number Diff line change
Expand Up @@ -345,107 +345,6 @@ class MainSideBarItem extends Play {
}
}

class MainSideBar extends Play {

_init() {

this.make(RectView, Vec2.make(0, 0), {
w: 580,
h: 900,
color: Color.black
})

let _
let tabs = [ ]

_ = this._make(MainSideBarItem, Vec2.make(0, 0), { icon: 'how to play', next: HowtoPlay })
tabs.push(_)
_ = this._make(MainSideBarItem, Vec2.make(0, _.height), { icon: 'settings', next: Settings })
tabs.push(_)
_ = this._make(MainSideBarItem, Vec2.make(0, _.height * 2), { icon: 'statistics', next: Statistics })
tabs.push(_)
_ = this._make(MainSideBarItem, Vec2.make(0, _.height * 3), { icon: 'about', next: About })
tabs.push(_)

this.make(Tabs, Vec2.make(4, 4), {
tabs
})


}
}

export class MainMenu extends Play {
_init() {

this.make(Background, Vec2.zero, undefined)

this.make(MainTitle, Vec2.make(6, 6), {})

this.make(MainSideBar, Vec2.make(1320, 100), {})

this.make(MainCards, Vec2.make(80, 260), {})

}
}


class MainCards extends Play {


_init() {
let w = 380
this.make(MainCard, Vec2.make(0, 0), {
text: 'solitaire'
})
this.make(MainCard, Vec2.make(w, 0), {
text: 'freecell'
})
this.make(MainCard, Vec2.make(w * 2, 0), {
text: 'spider'
})
}

}

type MainCardData = {
text: string
}

class MainCard extends Play {

get data() {
return this._data as MainCardData
}

_init() {

this.make(Anim, Vec2.make(0, 0), {
name: 'main_card_bg'
})

let text = this.make(Text, Vec2.make(-450, 200), {
text: this.data.text,
rotation: - Math.PI * 0.5,
color: Color.black
})


this.make(Clickable, Vec2.make(60, 64), {
rect: Rect.make(0, 0, 300, 420),
on_click() {
scene_transition.next(SolitairePlay)
},
on_hover() {
text.color = Color.red
},
on_hover_end() {
text.color = Color.black
}
})
}
}


class Statistics extends Play {
_init() {
Expand All @@ -456,7 +355,7 @@ class Statistics extends Play {
this.make(Navigation, Vec2.zero, {
route: 'statistics',
on_back() {
scene_transition.next(MainMenu)
//scene_transition.next(MainMenu)
}
})

Expand Down Expand Up @@ -710,115 +609,45 @@ class ScrollableListLongContent<T> extends Play {

}


export class Settings extends Play {
export class About2 extends Play {
_init() {

this.make(Background, Vec2.zero, undefined)

let self = this
this.make(Navigation, Vec2.zero, {
route: 'settings',
on_back() {
scene_transition.next(MainMenu)
}
})


let content = this._make(RectView, Vec2.make(0, 0), {
w: 100,
h: 100
})

this.make(ScrollableContent, Vec2.make(20, 120), {
w: 1880,
h: 940,
content
})

this.make(RectView, Vec2.zero, { w: 1920, h: 1080, color: Color.hex(0xb4beb4)})

}
}
export class About extends Play {
_init() {

this.make(Background, Vec2.zero, undefined)

let self = this
this.make(Navigation, Vec2.zero, {
route: 'about',
this.make(Navigation2, Vec2.zero, {
key: 'about',
on_back() {
scene_transition.next(MainMenu)
scene_transition.next(MainMenu2)
}
})

let w = 1880
let h = 940
this.make(Nine, Vec2.make(20, 120), {
name: 'panel_bg_nine_slice',
w: w,
h: h
})

let content = this._make(LongHyperText, Vec2.make(0, 0), {
width: 1880 - 80,
content: howtos['about']
})

this.make(ScrollableContent, Vec2.make(20, 120), {
w: 1880,
h: 940,
this.make(ScrollableContent, Vec2.make(60, 160), {
w: w - 100,
h: h - 80,
content
})


}
}

export class HowtoPlay extends Play {

_init() {

this.make(Background, Vec2.zero, undefined)

let self = this
this.make(Navigation, Vec2.zero, {
route: 'how_to_play',
on_back() {
scene_transition.next(MainMenu)
}
})

let w = 320
let tabs = [
this._make(Tab, Vec2.make(2, 2), {
text: 'solitaire',
w
}),
this._make(Tab, Vec2.make(2 + w + 4, 2), {
text: 'freecell',
w
}),
this._make(Tab, Vec2.make(2 + (w + 4) *2, 2), {
text: 'spider',
w
})
]

this.make(Tabs, Vec2.make(800, 8), {
tabs
})



let content = this._make(LongHyperText, Vec2.make(0, 0), {
width: 1880 - 80,
content: howtos['solitaire']
})

this.make(ScrollableContent, Vec2.make(20, 120), {
w: 1880,
h: 940,
content
})

}
}


type LongHyperTextData = {
width: number,
content: string
Expand Down Expand Up @@ -1063,6 +892,7 @@ export class TransText extends Play {
set text(_: string) {
this._text = _
this._text_view.text = this.text
this._text_view.size = this.size
}

get text() {
Expand Down Expand Up @@ -1101,6 +931,7 @@ export class TransText extends Play {
if (!this.data.no_trans) {
this.dispose_trans = Trans.register(() => {
this._text_view.text = Trans.key(this._text)
this._text_view.size = this.size
})
}
}
Expand Down Expand Up @@ -1148,8 +979,13 @@ export class Text extends Play {
this.data.text = text
}

_size!: number
get size() {
return this.data.size ?? 128
return this._size
}

set size(size: number) {
this._size = size
}

get width() {
Expand All @@ -1161,6 +997,7 @@ export class Text extends Play {
}

_init() {
this._size = this.data.size ?? 128
this.rotation = this.data.rotation ?? 0
this.origin = this.data.center ? Vec2.make(this.width / 2, 0) : Vec2.zero
}
Expand Down Expand Up @@ -2215,6 +2052,7 @@ export class MainMenu2 extends Play {
this.make(MainSideButton, Vec2.make(1300, side_y + side_h * 3), {
text: 'about',
on_click() {
scene_transition.next(About2)
}
})

Expand Down Expand Up @@ -2259,7 +2097,8 @@ class SceneTransition extends Play {
//this.current = this._make(MainMenu2, Vec2.zero, {})
//this.current = this._make(HowtoPlay2, Vec2.zero, {})
//this.current = this._make(Settings2, Vec2.zero, {})
this.current = this._make(SolitairePlay, Vec2.zero, {})
//this.current = this._make(SolitairePlay, Vec2.zero, {})
this.current = this._make(About2, Vec2.zero, {})

transition.set_matrix(Mat3x2.create_scale_v(Game.v_screen))
pallette.set_matrix(Mat3x2.create_scale_v(Game.v_screen))
Expand Down
2 changes: 1 addition & 1 deletion src/howtos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ The scoring system is:
let about = `
A hobby project, created in 2023 by [eguneys]"https://eguneys.github.io".
A fun way to pass time with 3 solitaire games. [Solitaire]"https://en.wikipedia.org/wiki/Klondike_(solitaire)", [Freecell]"https://en.wikipedia.org/wiki/FreeCell", and [Spider]"https://en.wikipedia.org/wiki/Spider_(solitaire)".
A fun way to pass time with 3 solitaire games. [Solitaire]"https://en.wikipedia.org/wiki/Klondike_(solitaire)", [Fourtimes]"https://en.wikipedia.org/wiki/FreeCell", and [Octopus]"https://en.wikipedia.org/wiki/Spider_(solitaire)".
- This project is free and open source at [Github]"https://github.com/eguneys/solitaire23"
- Other games will be linked here when available.
Expand Down
2 changes: 1 addition & 1 deletion src/showcase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { ticks } from './shared'
import { Anim } from './anim'
import { Tween } from './tween'

import { Text, RectView, Clickable, Background, MainMenu } from './game'
import { Text, RectView, Clickable, Background } from './game'
import { Button } from './ui'
import { Suit, Cards as OCards, Card as OCard, CardPov, hidden_card } from 'lsolitaire'

Expand Down
6 changes: 2 additions & 4 deletions src/solitaire.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,9 @@ import { bg1, link_color, Play, PlayType} from './play'
import { Anim } from './anim'

import { TransText, Text, RectView, Clickable, Background, MainMenu2 } from './game'
import { Settings2, HowtoPlay2 } from './game'
import { About2, Settings2, HowtoPlay2 } from './game'
import { scene_transition }from './game'

import { HowtoPlay, Settings, About } from './game'

import { n_seven, card_sort_key, Cards, Card as OCard, SolitairePov, Solitaire } from 'lsolitaire'

import { ticks } from './shared'
Expand Down Expand Up @@ -826,7 +824,7 @@ class SideBar extends Play {
this.make(SideBarItem, Vec2.make(x, y + h * 4), {
text: 'about',
on_click() {
scene_transition.next(About)
scene_transition.next(About2)
}
})
}
Expand Down
2 changes: 1 addition & 1 deletion src/solitaire_game.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { ticks } from './shared'
import { RNG, random, int_random, v_random, v_random_h, v_screen, arr_random } from './util'
import { Tween } from './tween'

import { Text, RectView, Clickable, Background, MainMenu } from './game'
import { Text, RectView, Clickable, Background } from './game'

import { SolitaireHooks } from './hooks'
import { make_solitaire_back } from './solitaire_back'
Expand Down
2 changes: 1 addition & 1 deletion src/ui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { bg1, link_color, Play, PlayType} from './play'
import { ticks } from './shared'
import { Anim } from './anim'

import { TransText, RectView, Clickable, Background, MainMenu } from './game'
import { TransText, RectView, Clickable, Background } from './game'

type ButtonData = {
text: string,
Expand Down

0 comments on commit fa98213

Please sign in to comment.