Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Next level visual fix #6

Merged
merged 32 commits into from
Jul 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
85587ef
Merge pull request #4 from b7g/next-level-visual
ASecondGuy Jun 29, 2022
521dbc8
menu scene tree refactor game page
ASecondGuy Jun 29, 2022
5b1175b
menu scene tree refactor about page
ASecondGuy Jun 29, 2022
97fcb5c
menu scene tree refactor settings page
ASecondGuy Jun 29, 2022
f13a63d
fix scroll to bug report
ASecondGuy Jun 29, 2022
1b2eb5f
Merge branch 'next-level-visual' of https://github.com/b7g/Suffragium…
ASecondGuy Jun 30, 2022
aa71c1d
Fixing stuff the merge broke
ASecondGuy Jun 30, 2022
046536a
Merge pull request #6 from ASecondGuy/b7g-next-level-visual
ASecondGuy Jun 30, 2022
f25d0ab
Fix title font and added margin container to main_theme.tres
ASecondGuy Jun 30, 2022
d97e7eb
fix about page crashing on reload
ASecondGuy Jun 30, 2022
113310c
game_card scene tree refactor
ASecondGuy Jun 30, 2022
9743b3b
game_card_add_yours scene tree refactor
ASecondGuy Jun 30, 2022
5d249f1
fix assert fail
ASecondGuy Jun 30, 2022
bf07df0
fix themes and theme overwrites
ASecondGuy Jun 30, 2022
d0f86f1
Merge branch 'next-level-visual' into next-level-visual-fix
ASecondGuy Jun 30, 2022
e543383
fix merge
ASecondGuy Jun 30, 2022
e18028b
rename About.gd to about.gd
ASecondGuy Jun 30, 2022
a737e8b
fix about page empty bottom part
ASecondGuy Jun 30, 2022
98e9722
Fixed most colors/margins
RedstoneMedia Jun 30, 2022
957df31
fix visuals
ASecondGuy Jun 30, 2022
c11f6c0
Disable bbcode for no reason
ASecondGuy Jul 1, 2022
02650fd
fix theme even more
ASecondGuy Jul 1, 2022
8dae945
Merge branch 'next-level-visual-fix' of https://github.com/ASecondGuy…
RedstoneMedia Jul 1, 2022
6431abb
Fixed more margins/color issues
RedstoneMedia Jul 1, 2022
dbce066
Merge pull request #7 from RedstoneMedia/asecondguy-next-level-visual…
ASecondGuy Jul 1, 2022
76b31f1
add much needed about.gd docu & make it respond to line spacing
ASecondGuy Jul 1, 2022
22f049f
fix visuals again
ASecondGuy Jul 2, 2022
3bcfb9c
refactor about.gd thanks to Numenters tip
ASecondGuy Jul 2, 2022
0bb36f7
Fixed play time game card position
RedstoneMedia Jul 2, 2022
b2562a0
fix more visuals
ASecondGuy Jul 2, 2022
59a955f
Merge branch 'next-level-visual-fix' of https://github.com/ASecondGuy…
RedstoneMedia Jul 2, 2022
14bed83
Merge pull request #8 from RedstoneMedia/asecondguy-next-level-visual…
ASecondGuy Jul 2, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
110 changes: 110 additions & 0 deletions game/app/scenes/about.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
tool
extends ScrollContainer
# This script translates a simplified syntax into bbcode for the RichTextLabel to display.
# It can also calculate the position of specific lines. This is used by menu to smooth scroll.
# How to edit the about page:
# -Edit the text property of this About node.
# -Everything will be translated using tr()
# (every key will be substituted anything else stays the same)
# -titles can be added by using the title_key at the start of the line.
# (this is a shorthand for using [font="res://.../titlefont.tres")
# -Any [url] tag will be treated like a link. If you add one color it the same as the others.
# (specific color is subject to change)

export(String) var title_key := "# "
# This is the About text. To add a Title use the title key
export(String, MULTILINE) var text := "" setget set_text
export(Font) var title_font: Font

onready var _label := $MC/RichTextLabel


# this is needed to ract to any language changes that might need retranslating
func _notification(what):
if what == NOTIFICATION_TRANSLATION_CHANGED:
_write_def()


func _ready():
_write_to_label()


func set_text(val: String):
text = val
# updating this is only needed in editor
# In-game it is updated by other sources
if Engine.editor_hint:
_write_def()


func _write_to_label():
# Fails in Editor when you edit the script.
if !is_instance_valid(_label):
return
# this part might need a refactor
_label.clear()
for line in text.split("\n"):
# this loop treats every line in sequence
var is_title: bool = line.begins_with(title_key)
line = line.trim_prefix(title_key)
if is_title:
_label.push_font(title_font)

# first refers to the first part of the line
var first := true
for key in line.split(" "):
# each part of this might be a translation key, one or more bb tags,
# one or more closing tags, or just text
if key.match("[/*]"):
# RichTextLabel requires pop() when closing tag from previus append_bbcode()
for _i in range(key.count("[")):
_label.pop()
else:
# append the translation of whatever key is
# anything not a key will be returned unchanged
# tr("[color=blue]") = "[color=blue]"
if first:
# the first part of the line shouldn't have a seperating " " infront of it
_label.append_bbcode(tr(key))
else:
_label.append_bbcode(" " + tr(key))
first = false
# close the [font] tag for the title font
if is_title:
_label.pop()
_label.newline()


# determines how far down to scroll until the line is found
# !this is searched in the untranslated text
func get_line_absolute_height(line: String):
var pos: float = 0
var lines: Array = text.split("\n")
var font_height: int = _label.get_font("normal_font").get_height()
var line_spacing: float = _label.get_constant("line_separation")

var line_location := text.find(line)
# count won't work if location is 0. If it is the height is also 0
if line_location == 0:
return 0
# go over every line and add its height
for i in text.count("\n", 0, line_location):
# i is the line to add the size of
if lines[i].begins_with(title_key):
pos += title_font.get_height()
else:
pos += font_height
pos += line_spacing
return pos


# helper to call _write_to_label deferred
# (_write_to_label will be called at the end of the frame after everything else)
func _write_def():
call_deferred("_write_to_label")


# This is called when the user clicks on a [url] tag in the label.
# Utils.open_url() actually supports more than just urls
func _on_RichTextLabel_meta_clicked(meta):
Utils.open_url(meta)
49 changes: 24 additions & 25 deletions game/app/scenes/game_card.gd
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
extends ColorRect
extends PanelContainer

var _game_config: ConfigFile = null
var _playtime: float = 0
var _last_played = -1

onready var _label_title := $MC/VC/HC/VC/MC/LabelTitle
onready var _label_description := $MC/VC/SC/MC/LabelDescription
onready var _texture_icon_rect := $MC/VC/HC/TextureRectIcon
onready var _label_playtime := $MC/VC/HC/VC/HC/LabelPlaytimeNumber
onready var _label_playtime_unit := $MC/VC/HC/VC/HC/LabelPlaytimeUnit
onready var _label_title := $Card/TitleSection/VC/LabelTitle
onready var _label_description := $Card/Description
onready var _texture_icon_rect := $Card/TitleSection/icon
onready var _label_playtime := $Card/TitleSection/VC/HC/LabelPlaytimeNumber
onready var _label_playtime_unit := $Card/TitleSection/VC/HC/LabelPlaytimeUnit

onready var _popup_label_title := $PopupDialogInfo/VC/PC/MC/HC/MC/VC/MC/LabelTitle
onready var _popup_label_description := $PopupDialogInfo/VC/PC2/MC/HC/SC/MC/VC/LabelDescription
onready var _popup_icon_rect := $PopupDialogInfo/VC/PC/MC/HC/TextureRectIcon
onready var _popup_label_author := $PopupDialogInfo/VC/PC2/MC/HC/VC/LabelAuthor
onready var _popup_label_version := $PopupDialogInfo/VC/PC2/MC/HC/VC/LabelVersion
onready var _popup_label_playtime := $PopupDialogInfo/VC/PC/MC/HC/MC/VC/HC/LabelPlaytimeNumber
onready var _popup_label_playtime_unit := $PopupDialogInfo/VC/PC/MC/HC/MC/VC/HC/LabelPlaytimeUnit
onready var _popup_label_playtime_2 := $PopupDialogInfo/VC/PC/MC/HC/MC/VC/HC/LabelPlaytimeNumber2
onready var _popup_label_playtime_unit_2 := $PopupDialogInfo/VC/PC/MC/HC/MC/VC/HC/LabelPlaytimeUnit2
onready var _popup_label_highscore := $PopupDialogInfo/VC/PC/MC/HC/VC/LabelHighscore
onready var _popup_label_title := $PopupDialogInfo/VC/TitleSection/HC/Title/LabelTitle
onready var _popup_label_description := $PopupDialogInfo/VC/InfoSection/HC/Description
onready var _popup_icon_rect := $PopupDialogInfo/VC/TitleSection/HC/TextureRectIcon
onready var _popup_label_author := $PopupDialogInfo/VC/InfoSection/HC/VC/LabelAuthor
onready var _popup_label_version := $PopupDialogInfo/VC/InfoSection/HC/VC/LabelVersion
onready var _popup_playtime := $PopupDialogInfo/VC/TitleSection/HC/Title/HC/LabelPlaytimeNumber
onready var _popup_playtime_2 := $PopupDialogInfo/VC/TitleSection/HC/Title/HC/LabelPlaytimeNumber2
onready var _popup_playtime_unit := $PopupDialogInfo/VC/TitleSection/HC/Title/HC/LabelPlaytimeUnit
onready var _popup_playtime_unit_2 := $PopupDialogInfo/VC/TitleSection/HC/Title/HC/LabelPlaytimeUnit2
onready var _popup_label_highscore := $PopupDialogInfo/VC/TitleSection/HC/HighScore/LabelHighscore


func setup(game_config: ConfigFile):
Expand All @@ -36,18 +36,17 @@ func setup(game_config: ConfigFile):
var playtime_unit = playtime_dict["unit"]

if playtime_dict.has("another_number"):
_popup_label_playtime_2.visible = true
_popup_label_playtime_2.text = playtime_dict["another_number"]
_popup_playtime_2.visible = true
_popup_playtime_2.text = playtime_dict["another_number"]
if playtime_dict.has("another_unit"):
_popup_label_playtime_unit_2.visible = true
_popup_label_playtime_unit_2.text = playtime_dict["another_unit"]
_popup_playtime_unit_2.visible = true
_popup_playtime_unit_2.text = playtime_dict["another_unit"]

var highscore_dict = GameManager.get_highscore(game_id)
if highscore_dict.has("score"):
_popup_label_highscore.text = str(highscore_dict["score"])
else:
$PopupDialogInfo/VC/PC/MC/HC/VC/Label.visible = false
$PopupDialogInfo/VC/PC/MC/HC/VC/LabelHighscore.visible = false
$PopupDialogInfo/VC/TitleSection/HC/HighScore.visible = false

_label_title.text = game_name
_label_description.text = game_description
Expand All @@ -58,8 +57,8 @@ func setup(game_config: ConfigFile):
_popup_label_description.text = game_description
_popup_label_author.text = game_config.get_value("game", "creator")
_popup_label_version.text = game_config.get_value("game", "version")
_popup_label_playtime.text = playtime_number
_popup_label_playtime_unit.text = playtime_unit
_popup_playtime.text = playtime_number
_popup_playtime_unit.text = playtime_unit

var icon_file_name = game_config.get_value("game", "icon")
var icon_path = GameManager.make_game_file_path(game_id, icon_file_name)
Expand Down Expand Up @@ -113,7 +112,7 @@ func _format_playtime(playtime: float) -> Dictionary:


func _on_ButtonInfo_pressed():
$PopupDialogInfo.popup_centered()
$PopupDialogInfo.popup_centered($PopupDialogInfo/VC.rect_size)


func _on_ButtonPlay_pressed():
Expand Down
Loading