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

Add notifications to the main screen for no games and invalid settings #170

Merged
merged 2 commits into from
Dec 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
20 changes: 20 additions & 0 deletions stellarisdashboard/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,26 @@ def localization_files(self):
f"Loaded {len(files)} localization files from {self.game_data_dirs}"
)
return files


@property
def save_file_path_is_valid(self):
return self.save_file_path is not None\
and self.save_file_path.is_dir()\
and next(self.save_file_path.glob("*/*.sav"), None) is not None

@property
def stellaris_install_path_is_valid(self):
return self.stellaris_install_path is not None\
and self.stellaris_install_path.is_dir()\
and (self.stellaris_install_path / "localisation").is_dir()\
and (self.stellaris_install_path / "flags/colors.txt").is_file()

@property
def stellaris_user_data_path_is_valid(self):
return self.stellaris_user_data_path is not None\
and self.stellaris_user_data_path.is_dir()\
and (self.stellaris_user_data_path / "dlc_load.json").is_file()


def _get_mod_data_dir(mod_descriptor_path: pathlib.Path):
Expand Down
46 changes: 41 additions & 5 deletions stellarisdashboard/dashboard_app/assets/style.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
body {
font-family: verdana;
font-family: verdana, system-ui;
background-color: rgba(33, 43, 39, 1);
font-size: 16px;
margin: 0;
Expand All @@ -23,19 +23,19 @@ h4, h5, h6 {

p, span {
color: rgba(217, 217, 217, 1);
font-family: verdana;
font-family: verdana, system-ui;
font-size: 16px;
}

a {
color: rgba(195, 133, 33, 1);
font-family: verdana;
font-family: verdana, system-ui;
font-size: 20px;
}

input {
color: rgba(0, 0, 0, 1);
font-family: verdana;
font-family: verdana, system-ui;
font-size: 20px;
}

Expand All @@ -46,7 +46,7 @@ a.button, input.button, button.button {
cursor: pointer;

color: rgba(195, 133, 33, 1);
font-family: verdana;
font-family: verdana, system-ui;
font-size: 16px;

background-color: rgba(43, 59, 52, 1);
Expand Down Expand Up @@ -214,3 +214,39 @@ a.textlink {
a.titlelink {
color: rgba(195, 133, 33, 1);
}

.notifications {
li {
list-style: none;
width: 60%;
margin-inline: auto;
border: 1px solid ;
padding: 1rem;
margin-bottom: 1rem;
max-width: 50rem;
border-radius: 0.5rem;
}

code {
background: rgba(0, 0, 0, 0.4);
padding: 0.25rem;
border-radius: 0.25rem;
}

a {
font-size: 1rem;
}

.warning {
border-color: rgba(195, 133, 33, 1);
background: hsl(37, 25%, 10%);
a {
color: hsl(37, 71%, 60%);
}
}

.info {
border-color: hsl(219, 79%, 66%);
background: hsl(219, 25%, 10%);
}
}
3 changes: 3 additions & 0 deletions stellarisdashboard/dashboard_app/game_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,7 @@ def index_page(version=None):
show_old_version_notice=show_old_version_notice,
version=utils.VERSION,
update_version_id=version,
save_file_path_is_valid=config.CONFIG.save_file_path_is_valid,
stellaris_install_path_is_valid=config.CONFIG.stellaris_install_path_is_valid,
stellaris_user_data_path_is_valid=config.CONFIG.stellaris_user_data_path_is_valid,
)
37 changes: 37 additions & 0 deletions stellarisdashboard/dashboard_app/templates/game_index.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,40 @@
{% extends "layout.html" %}
{% block body %}

<ul class="notifications">
{% if not save_file_path_is_valid %}
<li class="warning">
<h2>⚠️ Save files folder is invalid</h2>
<p>This folder should contain folders for each game, which each contain <code>.sav</code> files.</p>
<p><small>(Usually, this means you use cloud saves, which you need to configure manually. If the folder is correct, but you simply do not have any saved games, you can ignore this warning.)</small></p>
<p><a href="/settings">Go to Settings to change it, then restart the dashboard.</a></p>
</li>
{% endif %}
{% if not stellaris_install_path_is_valid %}
<li class="warning">
<h2>⚠️ Stellaris install folder is invalid</h2>
<p>This folder should contain the Stellaris install data, such as the <code>localisation</code> and <code>flags</code> folders.</p>
<p><small>(Usually this means your game is not installed in the default Steam location of your main drive.)</small></p>
<p><a href="/settings">Go to Settings to change it, then restart the dashboard.</a></p>
</li>
{% endif %}
{% if not stellaris_user_data_path_is_valid %}
<li class="warning">
<h2>⚠️ Stellaris user data folder is invalid</h2>
<p>This folder should contain the <code>dlc_load.json</code> file.</p>
<p><a href="/settings">Go to Settings to change it, then restart the dashboard.</a></p>
</li>
{% endif %}
{% if games|length == 0 %}
<li class="info">
<h2>ℹ️ No games available</h2>
<p>Don’t panic! Looks like this is your first time opening the dashboard.</p>
<p>To get started, create a new save now then refresh this page, or simply play until the next autosave then refresh.</p>
</li>
{% endif %}
</ul>

{% if games|length %}
<div class="gamelist">
<ul class=entries>
<h1>Available Games</h1>
Expand All @@ -17,5 +52,7 @@ <h1>Available Games</h1>
{% endfor %}
</ul>
</div>
{% endif %}

{% endblock %}

Loading