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 "Hide other players setting" #158

Merged
merged 9 commits into from
Jul 29, 2024
8 changes: 2 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,7 @@ If you installed Stellaris in the default location at (`C:/Program Files (x86)/S

If you play the game in another language, you can change the "Stellaris language" and restart the dashboard. Note that this setting should be the language code used by the game (ie `l_braz_por`, `l_english`, `l_french`, `l_german`, `l_japanese`, `l_korean`, `l_polish`, `l_russian`, `l_simp_chinese`, `l_spanish`).

If you use mods that add new names, the dashboard *should* automatically find the required files. Note that if you restart change your mod list, any new modded names will not be loaded until you restart the dashboard. If modded names are not working at all, you might need to change your "Stellaris user data folder" setting and restart the dashboard. This should be the folder containing the `dlc_load.json` file as well as the `mod/` folder.

## Colors

Currently, all country colors shown in the dashboard are randomized and completely unrelated to the colors in-game. Unfortunately, it is not that easy to get the country color from the save files, but it could be possible to add this in a future release.
If you use mods that add new names, the dashboard *should* automatically find the required files. Note that if you change your mod list, any new modded names will not be loaded until you restart the dashboard. If modded names are not working at all, you might need to change your "Stellaris user data folder" setting and restart the dashboard. This should be the folder containing the `dlc_load.json` file as well as the `mod/` folder.

## How to improve performance

Expand All @@ -133,7 +129,7 @@ If you find that the dashboard is too slow to browse, you can try some of these

### Multiplayer

Support for Multiplayer is **experimental**. The dashboard will avoid showing information about other player controlled empires, even if the "Show all empires" checkbox is ticked in the settings. To use the dashboard in multiplayer, you must first configure your multiplayer username in the dashboard settings menu.
Support for Multiplayer is **experimental**. The dashboard will avoid showing information about other player controlled empires, even if the "Show all empires" checkbox is ticked in the settings. To use the dashboard in multiplayer, you must first configure your multiplayer username in the dashboard settings menu. You can disable this behavior, uncheck the "Hide other players" setting.

### Observer Mode

Expand Down
2 changes: 1 addition & 1 deletion mod/stellaris_dashboard/descriptor.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ tags={
"Gameplay"
}
picture="thumbnail.png"
supported_version="3.6.*"
supported_version="v3.12.*"
remote_file_id="1466534202"
4 changes: 2 additions & 2 deletions stellarisdashboard/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ def f_monitor_saves(save_path=None, stop_event: threading.Event = None):
polling_interval = config.CONFIG.polling_interval
save_reader = save_parser.ContinuousSavePathMonitor(save_path)
save_reader.mark_all_existing_saves_processed()
tle = timeline.TimelineExtractor()

show_wait_message = True
while not stop_event.is_set():
Expand All @@ -80,6 +79,7 @@ def f_monitor_saves(save_path=None, stop_event: threading.Event = None):
continue
show_wait_message = True
nothing_new = False
tle = timeline.TimelineExtractor()
tle.process_gamestate(game_name, gamestate_dict)
visualization_data.get_current_execution_plot_data(game_name)
del gamestate_dict
Expand Down Expand Up @@ -112,13 +112,13 @@ def f_parse_saves(threads=None, save_path=None, game_name_prefix="") -> None:
save_path,
game_name_prefix=game_name_prefix,
)
tle = timeline.TimelineExtractor()
for (
game_name,
gamestate_dict,
) in save_reader.get_gamestates_and_check_for_new_files():
if gamestate_dict is None:
continue
tle = timeline.TimelineExtractor()
tle.process_gamestate(game_name, gamestate_dict)
del gamestate_dict

Expand Down
22 changes: 19 additions & 3 deletions stellarisdashboard/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,12 @@ def _get_default_stellaris_user_data_path():
# according to https://stellaris.paradoxwikis.com/Save-game_editing
home = pathlib.Path.home()
if platform.system() == "Windows":
return home / "Documents/Paradox Interactive/Stellaris/"
one_drive_path = home / "OneDrive/Documents/Paradox Interactive/Stellaris/"
non_one_drive_path = home / "OneDrive/Documents/Paradox Interactive/Stellaris/"
if one_drive_path.exists():
return one_drive_path
else:
return non_one_drive_path
elif platform.system() == "Linux":
return home / ".local/share/Paradox Interactive/Stellaris/"
else:
Expand Down Expand Up @@ -177,6 +182,7 @@ def _get_default_base_output_path():
stellaris_user_data_path=_get_default_stellaris_user_data_path(),
stellaris_language="l_english",
mp_username="",
hide_other_players=True,
base_output_path=_get_default_base_output_path(),
threads=1,
host="127.0.0.1",
Expand Down Expand Up @@ -225,6 +231,7 @@ class Config:
check_version: bool = None
filter_events_by_type: bool = None
show_everything: bool = None
hide_other_players: bool = None
read_all_countries: bool = None
show_all_country_types: bool = None
include_id_in_names: bool = None
Expand All @@ -242,16 +249,22 @@ class Config:

production: bool = False

PATH_KEYS = {
"base_output_path",
EXISTING_PATH_KEYS = {
# these paths should already exist
# if not, the setting is reset to default
# this helps with issues related to OneDrive
"save_file_path",
"stellaris_install_path",
"stellaris_user_data_path",
}
PATH_KEYS = EXISTING_PATH_KEYS | {
"base_output_path",
}
BOOL_KEYS = {
"check_version",
"filter_events_by_type",
"show_everything",
"hide_other_players",
"read_all_countries",
"show_all_country_types",
"log_to_file",
Expand Down Expand Up @@ -311,6 +324,8 @@ def _process_path_keys(self, key, val):
val = DEFAULT_SETTINGS[key]
else:
val = pathlib.Path(val)
if key in Config.EXISTING_PATH_KEYS and not val.exists():
val = DEFAULT_SETTINGS[key]
if key == "base_output_path":
try:
if not val.exists():
Expand Down Expand Up @@ -385,6 +400,7 @@ def __str__(self):
f" base_output_path: {repr(self.base_output_path)}",
f" threads: {repr(self.threads)}",
f" show_everything: {repr(self.show_everything)}",
f" hide_other_players: {repr(self.hide_other_players)}",
f" show_all_country_types: {repr(self.show_all_country_types)}",
]
return "\n".join(lines)
Expand Down
40 changes: 34 additions & 6 deletions stellarisdashboard/dashboard_app/assets/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,11 @@ input {
font-size: 20px;
}

a.button, input.button {
a.button, input.button, button.button {
-webkit-appearance: button;
-moz-appearance: button;
appearance: button;
cursor: pointer;

color: rgba(195, 133, 33, 1);
font-family: verdana;
Expand Down Expand Up @@ -83,19 +84,41 @@ li.toc-item {
}

form.settingsform {
padding: 0.25cm;
padding: 1rem
}

div.settings {
width: 80%;
max-width: 64rem;
color: rgba(217, 217, 217, 1);
margin: 1rem auto 0 auto;
}

.settingsbuttons {
margin-block-start: 1rem;
margin-inline-start: -1rem;
position: sticky;
bottom: 0;
}

.settings label,
.settings dt {
color: rgba(195, 133, 33, 1);
padding: 0.25cm;
margin: 0.25cm auto;
}

.settings dl {
display: flex;
gap: 0.25rem;
}

.settinginfo {
cursor: help;
}


div.setting {
padding: 0.1cm;
margin: 0.1cm;
margin: 0.1cm 0;

align-self: flex-start;

Expand All @@ -112,7 +135,12 @@ span.settingname {

span.settinginput {
align-self: flex-end;
flex: 1 0 20%;
flex: 1 0 40%;
}

span.settinginput input:not([type=checkbox]) {
box-sizing: border-box;
width: 100%;
}

div.objectdetails {
Expand Down
3 changes: 1 addition & 2 deletions stellarisdashboard/dashboard_app/graph_ledger.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,7 @@ def update_country_select_options(search):
for c in session.query(datamodel.Country):
if (
c.is_real_country()
and (c.has_met_player() or config.CONFIG.show_everything)
and not c.is_other_player
and not c.is_hidden_country()
):
options.append(
{"label": c.rendered_name, "value": c.country_id_in_game}
Expand Down
13 changes: 3 additions & 10 deletions stellarisdashboard/dashboard_app/history_ledger.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ def collect_event_dicts(self, event_list, key_object):
continue
if (
event.country
and any(c.is_other_player for c in event.involved_countries())
and any(c.is_hidden_country() for c in event.involved_countries())
and not event.event_is_known_to_player
):
continue
Expand Down Expand Up @@ -446,13 +446,7 @@ def system_details(self, system_model: datamodel.System) -> Dict[str, str]:
if bypasses:
details["Unknown Bypasses"] = ", ".join(bypasses)

if system_model.country is not None and (
system_model.country.has_met_player()
or (
config.CONFIG.show_everything
and not system_model.country.is_other_player
)
):
if system_model.country is not None and not system_model.country.is_hidden_country():
details["Owner"] = self._get_url_for(system_model.country)

details["Planets"] = ", ".join(
Expand Down Expand Up @@ -515,8 +509,7 @@ def country_details(self, country_model: datamodel.Country) -> Dict[str, str]:
relations_to_display = [
self._get_url_for(c)
for c in sorted(countries, key=lambda c: c.country_name)
if c.has_met_player()
or (config.CONFIG.show_everything and not c.is_other_player)
if not c.is_hidden_country()
]
if relations_to_display:
details[relation_type] = ", ".join(relations_to_display)
Expand Down
Loading
Loading