Fix inconsistencies with master

This commit is contained in:
Andrei Andreev 2023-02-16 20:17:23 +01:00
parent f645068afb
commit 0b048d78e7
19 changed files with 134 additions and 239 deletions

View File

@ -1,2 +1 @@
VUE_APP_DEV=false
VUE_APP_STEAM=true

View File

@ -2,7 +2,6 @@ import { ProgressChecker } from "../storage/progress-checker";
import CloudInvalidDataModal from "@/components/modals/cloud/CloudInvalidDataModal";
import CloudLoadConflictModal from "@/components/modals/cloud/CloudLoadConflictModal";
import CloudManualLoginModal from "@/components/modals/cloud/CloudManualLoginModal";
import CloudSaveConflictModal from "@/components/modals/cloud/CloudSaveConflictModal";
import EternityChallengeStartModal from "@/components/modals/challenges/EternityChallengeStartModal";
import InfinityChallengeStartModal from "@/components/modals/challenges/InfinityChallengeStartModal";
@ -308,7 +307,6 @@ function getSaveInfo(save) {
Modal.cloudSaveConflict = new Modal(CloudSaveConflictModal);
Modal.cloudLoadConflict = new Modal(CloudLoadConflictModal);
Modal.manualCloud = new Modal(CloudManualLoginModal);
Modal.cloudInvalidData = new Modal(CloudInvalidDataModal);
// eslint-disable-next-line max-params
Modal.addCloudConflict = function(saveId, saveComparison, cloudSave, localSave, onAccept) {

View File

@ -92,5 +92,3 @@ export * from "./ui/tab-notifications";
export * from "./speedrun";
export * from "./automator/script-templates";
export * from "./discord-parser";

View File

@ -460,7 +460,7 @@ GameDatabase.news = [
];
const game = games.randomElement();
return `An unidentified developer of Antimatter Dimensions would like to
recommend that you play <a href='${game.link}' target='_blank'>${game.name}</a>`;
recommend that you play <a href="${game.link}" target="_blank">${game.name}</a>`;
},
},
{
@ -2200,7 +2200,7 @@ GameDatabase.news = [
id: "a346",
text:
`Did you know Antimatter Dimensions is also available on Android? <a
href='https://play.google.com/store/apps/details?id=kajfosz.antimatterdimensions' target='_blank'>
href="https://play.google.com/store/apps/details?id=kajfosz.antimatterdimensions" target="_blank">
Click here to check it out!<a>`
},
{

View File

@ -1,3 +1,4 @@
import { STEAM } from "@/env";
import { GameDatabase } from "./game-database";
// NOTE: IF ANY COSTS ARE CHANGED HERE, THEY ALSO NEED TO BE CHANGED ON THE BACKEND TOO
@ -99,7 +100,7 @@ GameDatabase.shopPurchases = {
},
isUnlocked: () => PlayerProgress.realityUnlocked(),
lockText: "Reality",
},/*
},
allCosmeticSets: {
key: "allCosmeticSets",
cost: () => {
@ -121,5 +122,9 @@ GameDatabase.shopPurchases = {
},
isUnlocked: () => PlayerProgress.realityUnlocked(),
lockText: "Reality",
},*/
},
};
if (STEAM) {
delete GameDatabase.shopPurchases.allCosmeticSets;
}

View File

@ -1,17 +1,23 @@
/* eslint-disable import/extensions */
import { SteamRuntime } from "@/steam";
import { STEAM } from "@/env";
import pako from "pako/dist/pako.esm.mjs";
/* eslint-enable import/extensions */
//import { get, getDatabase, ref, set } from "firebase/database";
//import { getAuth, GoogleAuthProvider, signInWithPopup, signOut } from "firebase/auth";
import {
createUserWithEmailAndPassword,
getAuth,
GoogleAuthProvider,
signInWithEmailAndPassword,
signInWithPopup,
signOut
} from "firebase/auth";
import { get, getDatabase, ref, set } from "firebase/database";
import { initializeApp } from "firebase/app";
import { getAuth, signInWithPopup, signInWithEmailAndPassword, createUserWithEmailAndPassword, signOut, GoogleAuthProvider } from "firebase/auth";
import { getDatabase, ref, get, set } from "firebase/database";
import { sha512_256 } from "js-sha512";
import { decodeBase64Binary } from "./base64-binary";
import { ProgressChecker } from "./progress-checker";
import { SteamRuntime } from "@/steam";
const firebaseConfig = {
apiKey: "AIzaSyDuRTTluAFufmvw1zxGH6fsyEHmmbu8IHI",
@ -56,43 +62,24 @@ export const Cloud = {
async loginWithSteam(accountId, staticAccountId, screenName) {
if (this.loggedIn) {
Cloud.user.displayName = screenName;
return true;
return;
}
const email = `${accountId}@ad.com`;
const pass = staticAccountId;
try {
await Cloud.manualCloudCreate(email, pass);
await createUserWithEmailAndPassword(this.auth, email, pass);
} catch {
try {
await Cloud.manualCloudLogin(email, pass);
await signInWithEmailAndPassword(this.auth, email, pass);
} catch (error) {
// eslint-disable-next-line no-console
console.log(`Firebase Login Error: ${error}`);
return false;
return;
}
}
Cloud.user.displayName = screenName;
return true;
},
async manualCloudLogin(EmailAddress,Password) {
//try{
await signInWithEmailAndPassword(this.auth, EmailAddress, Password)
/*}catch(error){
console.log(`Could Not Login (Error: ${error}`)
Cloud.manualCloudCreate(EmailAddress,Password)
}*/
},
async manualCloudCreate(EmailAddress,Password) {
//try{
await createUserWithEmailAndPassword(this.auth, EmailAddress, Password);
/*}catch(error){
console.log(`Could Not Create (Error: ${error}`)
Cloud.manualCloudLogin(EmailAddress,Password)
}*/
},
// NOTE: This function is largely untested due to not being used at any place within web reality code
@ -171,7 +158,14 @@ export const Cloud = {
const slot = GameStorage.currentSlot;
this.writeToCloudDB(slot, serializedSave);
GameUI.notify.info(`Game saved (slot ${slot + 1}) to cloud as user ${this.user.displayName}`)
if (STEAM) {
GameUI.notify.info(`Game saved (slot ${slot + 1}) to cloud as user ${this.user.displayName}`);
return;
}
if (player.options.hideGoogleName) GameUI.notify.info(`Game saved (slot ${slot + 1}) to cloud`);
else GameUI.notify.info(`Game saved (slot ${slot + 1}) to cloud as user ${this.user.displayName}`);
},
async loadCheck() {
@ -188,7 +182,14 @@ export const Cloud = {
// eslint-disable-next-line no-loop-func
const overwriteLocalSave = () => {
GameStorage.overwriteSlot(saveId, cloudSave);
GameUI.notify.info(`Cloud save loaded`);/* for user ${this.user.displayName}`);*/
if (STEAM) {
GameUI.notify.info(`Cloud save loaded`);
return;
}
if (player.options.hideGoogleName) GameUI.notify.info(`Cloud save (slot ${saveId + 1}) loaded`);
else GameUI.notify.info(`Cloud save (slot ${saveId + 1}) loaded for user ${this.user.displayName}`);
};
// If the comparison fails, we assume the cloud data is corrupted and show the relevant modal
@ -258,12 +259,16 @@ export const Cloud = {
if (user) {
this.user = {
id: user.uid,
displayName: SteamRuntime.isActive
displayName: STEAM
? SteamRuntime.screenName
: user.displayName,
email: user.email,
};
SteamRuntime.syncIap();
if (STEAM) {
SteamRuntime.syncIAP();
} else {
ShopPurchaseData.syncSTD();
}
} else {
this.user = null;
}

View File

@ -1,10 +1,8 @@
import { SteamRuntime } from "@/steam";
import * as ADNotations from "@antimatter-dimensions/notations";
import { DEV } from "@/env";
import { deepmergeAll } from "@/utility/deepmerge";
import { Achievement } from "../achievements/normal-achievement";
export const GameStorage = {
currentSlot: 0,

View File

@ -1,4 +1,5 @@
<script>
import { STEAM } from "@/env";
import { SteamRuntime } from "@/steam";
import Payments from "../../../javascripts/core/payments";
@ -16,7 +17,11 @@ export default {
},
methods: {
purchase() {
SteamRuntime.purchaseIap(this.amount);
if (STEAM) {
SteamRuntime.purchaseIAP(this.amount);
} else {
Payments.buyMoreSTD(this.amount, this.cost);
}
}
},

View File

@ -1,88 +0,0 @@
<script>
import ModalWrapperChoice from "@/components/modals/ModalWrapperChoice";
import PrimaryButton from "@/components/PrimaryButton";
export default {
name: "CloudManualLoginModal",
components: {
ModalWrapperChoice,
PrimaryButton
},
data() {
return {
email: "",
pass: "",
error: false,
errorMessage: ""
};
},
computed: {
inputIsValid(){
return /\S+@\S+\.\S+/.test(this.email) && this.pass.length >= 6
}
},
methods: {
textEntry(){
this.error = false;
this.errorMessage = "";
},
async login(){
try{
await Cloud.manualCloudCreate(this.email,this.pass);
}catch(e){
console.log(e);
try{
await Cloud.manualCloudLogin(this.email, this.pass)
}catch(LoginError){
this.error = true;
this.errorMessage = "Unable to login, please recheck email/password";
return;
}
}
this.emitClose();
}
},
};
</script>
<template>
<ModalWrapperChoice
:show-cancel="!inputIsValid"
:show-confirm="false"
>
<template #header>
Cloud Login/Create
</template>
<div style="text-align:right">
<span>Email Address: </span>
<input
ref="email"
v-model="email"
type="text"
@keypress="textEntry"
@keyup.esc="emitClose"
><br>
<span>Password: </span>
<input
ref="pass"
v-model="pass"
type="password"
@keypress="textEntry"
@keyup.esc="emitClose"
>
</div>
<div
ref="showError"
v-if="error"
>
{{errorMessage}}
</div>
<PrimaryButton
v-if="inputIsValid"
class="o-primary-btn--width-medium c-modal-message__okay-btn c-modal__confirm-btn"
@click="login"
>
Login/Join
</PrimaryButton>
</ModalWrapperChoice>
</template>

View File

@ -11,7 +11,8 @@ export default {
updateIndicies: [],
visible: [],
timeStudyUnlocked: false,
glyphSacUnlocked: false
glyphSacUnlocked: false,
isElectron: false
};
},
computed: {
@ -57,6 +58,7 @@ export default {
const progress = PlayerProgress.current;
this.timeStudyUnlocked = progress.isEternityUnlocked;
this.glyphSacUnlocked = RealityUpgrade(19).isBought;
this.isElectron = ElectronRuntime.isActive;
},
format(x) {
switch (x) {
@ -147,22 +149,25 @@ export default {
a numpad key with <kbd>shift</kbd> will not buy a single Dimension. It may instead, depending on your device,
cause the page to scroll or change game tabs. <kbd>alt</kbd> will still work as expected.
</span>
<br>
<div class="l-modal-hotkeys-row">
<span class="c-modal-hotkeys-row__name l-modal-hotkeys-row__name">Window Zoom</span>
<kbd>-</kbd><kbd>0</kbd><kbd>+</kbd>
</div>
<span class="c-modal-hotkeys__shift-description">
To adjust zoom level, hold <kbd>ctrl</kbd> and press either <kbd>-</kbd> or <kbd>+</kbd> to decrease or increase zoom. <kbd>ctrl</kbd><kbd>0</kbd> will reset zoom to 100%.
</span>
<br>
<div class="l-modal-hotkeys-row">
<span class="c-modal-hotkeys-row__name l-modal-hotkeys-row__name">Fullscreen</span>
<kbd>F10</kbd>
</div>
<span class="c-modal-hotkeys__shift-description">
To enter or exit fullscreen, press <kbd>F10</kbd>.
</span>
<template v-if="isElectron">
<br>
<div class="l-modal-hotkeys-row">
<span class="c-modal-hotkeys-row__name l-modal-hotkeys-row__name">Window Zoom</span>
<kbd>-</kbd><kbd>0</kbd><kbd>+</kbd>
</div>
<span class="c-modal-hotkeys__shift-description">
To adjust zoom level, hold <kbd>ctrl</kbd> and press either <kbd>-</kbd> or <kbd>+</kbd> to decrease or
increase zoom. <kbd>ctrl</kbd><kbd>0</kbd> will reset zoom to 100%.
</span>
<br>
<div class="l-modal-hotkeys-row">
<span class="c-modal-hotkeys-row__name l-modal-hotkeys-row__name">Fullscreen</span>
<kbd>F10</kbd>
</div>
<span class="c-modal-hotkeys__shift-description">
To enter or exit fullscreen, press <kbd>F10</kbd>.
</span>
</template>
</div>
</span>
</ModalWrapper>

View File

@ -5,6 +5,8 @@ import OptionsButton from "@/components/OptionsButton";
import PrimaryToggleButton from "@/components/PrimaryToggleButton";
import SaveFileName from "./SaveFileName";
import { STEAM } from "@/env";
export default {
name: "OptionsSavingTab",
components: {
@ -38,6 +40,9 @@ export default {
return this.forceCloudOverwrite
? `Your local save will always overwrite your cloud save no matter what.`
: `Save conflicts will prevent your local save from being saved to the cloud.`;
},
STEAM() {
return STEAM;
}
},
watch: {
@ -192,23 +197,33 @@ export default {
<span v-else>Cloud Saving has been disabled on this save.</span>
</div>
<div class="l-options-grid">
<!--div
<div
v-if="!STEAM"
class="l-options-grid__row"
>
<OptionsButton
v-if="loggedIn"
onclick="GameOptions.logout()"
>
Disconnect Steam Account and disable Cloud Saving
Disconnect Google Account and disable Cloud Saving
</OptionsButton>
<OptionsButton
v-else
v-tooltip="'This will connect your Google Account to your Antimatter Dimensions savefiles'"
onclick="Modal.manualCloud.show()"
:class="{ 'o-pelle-disabled-pointer': creditsClosed }"
onclick="GameOptions.login()"
>
Login with Google to enable Cloud Saving
</OptionsButton>
</div-->
<PrimaryToggleButton
v-if="loggedIn"
v-model="hideGoogleName"
v-tooltip="'This will hide your Google Account name from the UI for privacy. Saving/loading is unaffected.'"
class="o-primary-btn--option l-options-grid__button"
:class="{ 'o-pelle-disabled-pointer': creditsClosed }"
label="Hide Google Account name:"
/>
</div>
<div
v-if="loggedIn"
class="l-options-grid__row"

View File

@ -1,48 +0,0 @@
<script>
import { ElectronRuntime } from "@/steam";
import SliderComponent from "@/components/SliderComponent";
export default {
name: "ZoomLevelSlider",
components: {
SliderComponent
},
data() {
return {
zoomLevel: 0
};
},
computed: {
sliderProps() {
return {
min: 50,
max: 150,
interval: 10,
width: "100%",
tooltip: false
};
}
},
methods: {
update() {
this.zoomLevel = Math.round(ElectronRuntime.zoomFactor * 100);
},
adjustSliderValue(value) {
this.zoomLevel = value;
ElectronRuntime.zoomLevel = Math.round(value / 10) / 10;
}
}
};
</script>
<template>
<div class="o-primary-btn o-primary-btn--option o-primary-btn--slider l-options-grid__button">
<b>Zoom Level: {{ formatInt(zoomLevel) }}%</b>
<SliderComponent
class="o-primary-btn--slider__slider"
v-bind="sliderProps"
:value="zoomLevel"
@input="adjustSliderValue($event)"
/>
</div>
</template>

View File

@ -30,19 +30,14 @@ export default {
};
},
computed: {
STEAM() {
return STEAM;
},
purchases() {
return ShopPurchase.all;
},
buySTDText() {
return STEAM ? "Buy More" : "Play Online on Steam to buy STDs";
}
},
watch: {
IAPsDisabled(newValue) {
player.IAP.disabled = newValue;
},
enableText() {
return `In-app Purchases: ${player.IAP.enabled ? "Enabled" : "Disabled"}`;
return `In-app Purchases: ${this.IAPsEnabled ? "Enabled" : "Disabled"}`;
},
respecText() {
if (!this.loggedIn) return "Not logged in!";
@ -114,30 +109,37 @@ export default {
label="Disable in-app-purchases:"
@click="toggleEnable()"
>
{{ `In-app Purchases: ${IAPsEnabled ? "Enabled" : "Disabled"}` }}
{{ enableText }}
</PrimaryButton>
<!--PrimaryButton
<PrimaryButton
v-if="!STEAM"
v-tooltip="respecText"
:class="respecClass()"
@click="respec()"
>
Respec Shop
</PrimaryButton-->
</PrimaryButton>
</div>
<!--div v-if="loggedIn && !canRespec">
<div v-if="loggedIn && !canRespec && !STEAM">
Time until respec available: {{ respecTimeStr }}
</div-->
</div>
<div
v-if="loggedIn"
class="c-login-info"
>
You are logged in as {{ username }}.
<!--button
class="o-shop-button-button"
onclick="GameOptions.logout()"
>
Disconnect Google Account
</button-->
<template v-if="STEAM">
You are logged in as {{ username }}.
</template>
<template v-else>
<span v-if="hiddenName">You are logged in. <i>(name hidden)</i></span>
<span v-else>You are logged in as {{ username }}.</span>
<button
class="o-shop-button-button"
onclick="GameOptions.logout()"
>
Disconnect Google Account
</button>
</template>
</div>
<div
v-else

View File

@ -80,7 +80,9 @@ export default {
window.openNewsLink = openExternalLink;
text = text
.replace(/href='/gu, `onClick='window.openNewsLink("`)
.replace(/' target='_blank'/gu, `")'`);
.replace(/' target='_blank'/gu, `")'`)
.replace(/href="/gu, `onClick='window.openNewsLink("`)
.replace(/" target="_blank"/gu, `")'`);
}
line.innerHTML = text;

View File

@ -1,4 +1,4 @@
import { NodeModule } from "../node-module";
import { NodeModule } from "./node-module";
/**
* @type {NodeModule<any>}

View File

@ -1,4 +1,4 @@
import { NodeModule } from "../node-module";
import { NodeModule } from "./node-module";
/**
* @type {NodeModule<Greenworks.NodeModule>}

View File

@ -8,7 +8,7 @@ export function hasPendingPurchaseConfirmations() {
return MAC && pendingConfirmations.length > 0;
}
export async function purchaseIap(std) {
export async function purchaseIAP(std) {
const itemId = `${std}STD`;
const quantity = 1;
const annotation = "Purchased via in-game store";
@ -51,10 +51,10 @@ async function validatePurchase(orderId) {
pendingConfirmations = pendingConfirmations.filter(item => item !== orderId);
await PlayFab.AddUserVirtualCurrency(stdsBought, "ST");
GameUI.notify.info(`${stdsBought} STDs Obtained!`);
syncIap();
syncIAP();
}
export async function syncIap() {
export async function syncIAP() {
const userInventory = await PlayFab.GetUserInventory();
ShopPurchaseData.totalSTD = userInventory.VirtualCurrency?.ST ?? 0;
for (const key of Object.keys(GameDatabase.shopPurchases)) {
@ -71,7 +71,7 @@ export async function syncIap() {
export async function purchaseShopItem(key, cost, cosmeticName) {
await PlayFab.PurchaseItem(key, cost, "ST");
await storeCosmetic(cosmeticName);
syncIap();
syncIAP();
}
async function storeCosmetic(name) {

View File

@ -3,9 +3,9 @@ import { RichPresenceInfo } from "../../javascripts/core/discord-parser";
import {
hasPendingPurchaseConfirmations,
purchaseIap,
purchaseIAP,
purchaseShopItem,
syncIap,
syncIAP,
validatePurchases
} from "./steam-purchases";
@ -72,12 +72,12 @@ export const SteamRuntime = {
Greenworks.activateAchievement(`Achievement${id}`);
},
async purchaseIap(std) {
async purchaseIAP(std) {
if (!this.isActive) {
return;
}
await purchaseIap(std);
await purchaseIAP(std);
},
validatePurchases() {
@ -88,12 +88,12 @@ export const SteamRuntime = {
validatePurchases();
},
async syncIap() {
async syncIAP() {
if (!this.isActive) {
return;
}
await syncIap();
await syncIAP();
},
async purchaseShopItem(key, cost, cosmeticName) {
@ -127,6 +127,7 @@ async function loginPlayFab(steamId) {
await PlayFab.LoginWithSteam(ticket.ticket.toString("hex"), screenName);
PlayFab.UpdateUserTitleDisplayName(screenName);
GameUI.notify.info("Logged in to PlayFab Cloud");
syncIAP();
} catch (error) {
GameUI.notify.error("Couldn't log in to PlayFab Cloud.");
throw error;
@ -137,9 +138,7 @@ async function loginFirebase(steamId) {
const accountId = steamId.accountId;
const staticAccountId = steamId.staticAccountId;
const screenName = steamId.screenName;
if (await Cloud.loginWithSteam(accountId, staticAccountId, screenName)) {
syncIap();
}
await Cloud.loginWithSteam(accountId, staticAccountId, screenName);
}
function initializeDiscord() {