Merge pull request #1463 from IvarK/omsi_news

Improved news ticker settings, AI news, new news messages
This commit is contained in:
Jane Doe 2020-06-03 19:59:00 -07:00 committed by GitHub
commit 15d122d03d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 4430 additions and 47 deletions

View File

@ -367,6 +367,7 @@
<script type="text/javascript" src="javascripts/components/modals/modal-start-infinity-challenge.js"></script>
<script type="text/javascript" src="javascripts/components/modals/modal-start-eternity-challenge.js"></script>
<script type="text/javascript" src="javascripts/components/modals/options/modal-options.js"></script>
<script type="text/javascript" src="javascripts/components/modals/options/modal-news-options.js"></script>
<script type="text/javascript" src="javascripts/components/modals/options/modal-animation-options.js"></script>
<script type="text/javascript" src="javascripts/components/modals/options/modal-confirmation-options.js"></script>
<script type="text/javascript" src="javascripts/components/modals/options/modal-info-display-options.js"></script>

View File

@ -52,13 +52,14 @@ Vue.component("news-ticker", {
.filter(message => message.isAdvertising && isUnlocked(message))
.randomElement();
} else {
const isAI = Math.random() < player.options.news.AIChance;
this.currentNews = GameDatabase.news
.filter(message => message.id.includes("ai") === isAI)
.filter(message => !this.recentTickers.includes(message) && isUnlocked(message))
.randomElement();
// Prevent tickers from repeating if they were seen recently
const repeatBuffer = 0.1 * GameDatabase.news.length;
this.recentTickers.push(this.currentNews.id);
if (this.recentTickers.length > repeatBuffer) this.recentTickers.shift();
while (this.recentTickers.length > player.options.news.repeatBuffer) this.recentTickers.shift();
}
if (this.currentNews.reset) {
this.currentNews.reset();
@ -67,7 +68,7 @@ Vue.component("news-ticker", {
line.innerHTML = this.currentNews.text;
line.style["transition-duration"] = "0ms";
if (this.currentNews && this.currentNews.id === "a244") {
if (this?.currentNews.id === "a244" || this?.currentNews.id === "ai63" ) {
line.style.transform = "translateX(-100%)";
} else {
line.style.transform = "translateX(0)";
@ -80,7 +81,7 @@ Vue.component("news-ticker", {
const line = this.$refs.line;
// SCROLL_SPEED is in pixels per second
const SCROLL_SPEED = 100;
const SCROLL_SPEED = player.options.news.speed * 100;
const scrollDuration = (this.$refs.ticker.clientWidth + line.clientWidth) / SCROLL_SPEED;
line.style["transition-duration"] = `${scrollDuration}s`;

View File

@ -0,0 +1,81 @@
"use strict";
Vue.component("modal-news-options", {
mixins: [modalOptionsMixin],
data() {
return {
enabled: false,
repeatBuffer: 40,
AIChance: 0,
speed: 1
};
},
watch: {
type(newValue) {
player.options.news.type = newValue;
},
repeatBuffer(newValue) {
player.options.news.repeatBuffer = parseInt(newValue, 10);
},
AIChance(newValue) {
player.options.news.AIChance = parseFloat(newValue, 10);
},
speed(newValue) {
player.options.news.speed = parseFloat(newValue, 10);
},
},
computed: {
newsOnOffLabel() {
return `News: ${this.enabled ? "On" : "Off"}`;
}
},
methods: {
update() {
const options = player.options.news;
this.enabled = options.enabled;
this.repeatBuffer = options.repeatBuffer;
this.AIChance = options.AIChance;
this.speed = options.speed;
}
},
template: `
<modal-options @close="emitClose">
<primary-button
class="o-primary-btn--option"
onclick="GameOptions.toggleNews()"
>{{ newsOnOffLabel }}</primary-button>
<div class="o-primary-btn o-primary-btn--option o-primary-btn--slider">
<b>{{ formatInt(parseInt(repeatBuffer)) }} message repeat buffer</b>
<input
v-model="repeatBuffer"
class="o-primary-btn--slider__slider"
type="range"
min="0"
step="1"
max="80"
/>
</div>
<div class="o-primary-btn o-primary-btn--option o-primary-btn--slider">
<b>{{ formatPercents(parseFloat(AIChance)) }} AI messages</b>
<input
v-model="AIChance"
class="o-primary-btn--slider__slider"
type="range"
min="0"
step="0.01"
max="1"
/>
</div>
<div class="o-primary-btn o-primary-btn--option o-primary-btn--slider">
<b>{{ formatPercents(parseFloat(speed)) }} scroll speed</b>
<input
v-model="speed"
class="o-primary-btn--slider__slider"
type="range"
min="0.5"
step="0.01"
max="2"
/>
</div>
</modal-options>`
});

View File

@ -74,11 +74,11 @@ Vue.component("options-gameplay-tab", {
class="o-primary-btn--option"
onclick="Modal.confirmationOptions.show()"
>Open Confirmation Options</options-button>
<div class="o-primary-btn o-primary-btn--option o-primary-btn--update-rate l-options-grid__button">
<b>Offline ticks: {{ formatInt(offlineTicks) }}</b>
<div class="o-primary-btn o-primary-btn--option o-primary-btn--slider l-options-grid__button">
<b>Offline ticks: {{ formatInt(parseInt(offlineTicks)) }}</b>
<input
v-model="offlineTicks"
class="o-primary-btn--update-rate__slider"
class="o-primary-btn--slider__slider"
type="range"
min="100"
step="100"

View File

@ -16,20 +16,18 @@ Vue.component("options-saving-tab", {
default: 30
},
},
template:
`
<div class="o-primary-btn o-primary-btn--option o-primary-btn--autosave-slider l-options-grid__button">
template: `
<div class="o-primary-btn o-primary-btn--option o-primary-btn--slider l-options-grid__button">
<b>Autosave interval: {{ formatInt(value) }}s</b>
<input
:value="value"
class="o-primary-btn--autosave-slider"
class="o-primary-btn--slider__slider"
type="range"
min="10"
max="60"
@input="emitInput(parseInt($event.target.value))"
/>
</div>
`
</div>`
}
},
data() {

View File

@ -16,12 +16,12 @@ Vue.component("options-visual-tab", {
default: 50
},
},
template:
`<div class="o-primary-btn o-primary-btn--option o-primary-btn--update-rate l-options-grid__button">
template: `
<div class="o-primary-btn o-primary-btn--option o-primary-btn--slider l-options-grid__button">
<b>Update rate: {{ formatInt(value) }} ms</b>
<input
:value="value"
class="o-primary-btn--update-rate__slider"
class="o-primary-btn--slider__slider"
type="range"
min="33"
max="200"
@ -36,7 +36,6 @@ Vue.component("options-visual-tab", {
notation: "",
commas: false,
updateRate: 0,
news: true,
autosaveInterval: 3000,
};
},
@ -58,9 +57,6 @@ Vue.component("options-visual-tab", {
},
UILabel() {
return `UI: ${this.$viewModel.newUI ? "New" : "Old"}`;
},
newsOnOffLabel() {
return `News: ${this.news ? "On" : "Off"}`;
}
},
methods: {
@ -70,7 +66,6 @@ Vue.component("options-visual-tab", {
this.notation = options.notation;
this.commas = options.commas;
this.updateRate = options.updateRate;
this.news = options.news;
},
hardReset() {
if (confirm("Do you really want to erase all your progress?")) {
@ -91,9 +86,9 @@ Vue.component("options-visual-tab", {
oninput="GameOptions.refreshUpdateRate()"
/>
<options-button
class="o-primary-btn--option_font-large"
onclick="GameOptions.toggleNews()"
>{{ newsOnOffLabel }}</options-button>
class="o-primary-btn--option"
onclick="Modal.newsOptions.show();"
>Open News Options</options-button>
</div>
<div class="l-options-grid__row">
<expanding-control-box width-source="header" class="l-options-grid__button c-options-grid__notations">

View File

@ -53,6 +53,7 @@ class ChallengeConfirmationModal extends Modal {
Modal.h2p = new Modal("modal-h2p");
Modal.shortcuts = new Modal("modal-shortcuts");
Modal.newsOptions = new Modal("modal-news-options");
Modal.animationOptions = new Modal("modal-animation-options");
Modal.confirmationOptions = new Modal("modal-confirmation-options");
Modal.infoDisplayOptions = new Modal("modal-info-display-options");

View File

@ -3,8 +3,8 @@
class GameOptions {
static toggleNews() {
player.options.news = !player.options.news;
ui.view.news = player.options.news;
player.options.news.enabled = !player.options.news.enabled;
ui.view.news = player.options.news.enabled;
GameStorage.save(true);
}

View File

@ -499,7 +499,12 @@ let player = {
saveOverThresholdFlag: false,
saveOverThresholdFlagModalDisplayed: false,
options: {
news: true,
news: {
enabled: true,
repeatBuffer: 40,
AIChance: 0,
speed: 1
},
notation: "Mixed scientific",
retryChallenge: false,
retryCelestial: false,

File diff suppressed because it is too large Load Diff

View File

@ -720,6 +720,14 @@ GameStorage.devMigrations = {
player.dimensions.antimatter[i].amount = new Decimal(dimension.amount);
}
delete player.dimensions.normal;
},
player => {
player.options.news = {
enabled: player.options.news,
repeatBuffer: 40,
AIChance: 0,
speed: 1
};
}
],

View File

@ -439,7 +439,7 @@ GameStorage.migrations = {
},
renameNewsOption(player) {
player.options.news = !player.options.newsHidden;
player.options.news.enabled = !player.options.newsHidden;
delete player.options.newsHidden;
},

View File

@ -131,7 +131,7 @@ const GameStorage = {
NormalChallenge(1).complete();
}
ui.view.news = player.options.news;
ui.view.news = player.options.news.enabled;
ui.view.newUI = player.options.newUI;
ui.view.tutorialState = player.tutorialState;
ui.view.tutorialActive = player.tutorialActive;

View File

@ -654,9 +654,9 @@ button:focus {
}
@keyframes a-existence-glow {
0% { text-shadow: 1px 1px 2px black; }
50% { text-shadow: 1px 1px 8px black; }
100% { text-shadow: 1px 1px 2px black; }
0% { color: var(--color-text-inverted); text-shadow: 0.1rem 0.1rem 0.2rem var(--color-text); }
50% { color: var(--color-text-inverted); text-shadow: 0.1rem 0.1rem 0.8rem var(--color-text); }
100% { color: var(--color-text-inverted); text-shadow: 0.1rem 0.1rem 0.2rem var(--color-text); }
}
[ach-tooltip] {
@ -1235,6 +1235,10 @@ screen and (max-width: 480px) {
box-sizing: border-box;
}
.o-primary-btn--option_font-med {
font-size: 1.4rem;
}
.o-primary-btn--option_font-large {
font-size: 1.8rem;
}
@ -1243,14 +1247,12 @@ screen and (max-width: 480px) {
font-size: 2rem;
}
.o-primary-btn--update-rate {
font-size: 1.4rem;
text-align: center;
cursor: default;
.o-primary-btn--slider__slider {
width: 100%;
}
.o-primary-btn--update-rate__slider {
width: 100%;
.o-primary-btn--slider {
cursor: default;
}
.o-primary-btn--modal-close {