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

MISC: Convert Literature entries and helper functions to TSX #1854

Open
wants to merge 4 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 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
4 changes: 2 additions & 2 deletions src/Literature/Literature.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ interface LiteratureConstructorParams {
title: string;
filename: LiteratureName;
factionRumors?: FactionName[];
text: string;
text: JSX.Element;
}
/**
* Lore / world building literature files that can be found on servers.
Expand All @@ -15,7 +15,7 @@ export class Literature {
title: string;
filename: LiteratureName & FilePath;
factionRumors: FactionName[];
text: string;
text: JSX.Element;

constructor({ title, filename, factionRumors, text }: LiteratureConstructorParams) {
this.title = title;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Literatures } from "./Literatures";
import { dialogBoxCreate } from "../ui/React/DialogBox";
import { LiteratureName } from "@enums";
import { Player } from "@player";
import React from "react";

export function showLiterature(fn: LiteratureName): void {
const litObj = Literatures[fn];
Expand All @@ -11,6 +12,13 @@ export function showLiterature(fn: LiteratureName): void {
for (const factionName of litObj.factionRumors) {
Player.receiveRumor(factionName);
}
const txt = `<i>${litObj.title}</i><br><br>${litObj.text}`;
const txt = (
<>
<i>{litObj.title}</i>
<br />
<br />
{litObj.text}
</>
);
dialogBoxCreate(txt, true);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
dialogBoxCreate(txt, true);
dialogBoxCreate(txt);

The second parameter should not be used. We only use it in 2 cases:

  • Literature. We concatenate strings to create an HTML string, so we need HTML support in dialogBoxCreate.
  • ns.alert. Legacy support.

Literature content is a React element now, so there is no need to call dialogBoxCreate with html=true.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

I only left it in due to my own uncertainty over what it controlled, and didn't try removing it, as it didn't produce any erroneous output. Thanks for the pointer!

}
Loading