Skip to content

Commit

Permalink
merge: from origin main
Browse files Browse the repository at this point in the history
  • Loading branch information
ultraviolet-jordan committed Apr 8, 2024
2 parents 9079210 + 8ce8fbe commit 269d04e
Show file tree
Hide file tree
Showing 40 changed files with 1,978 additions and 1,543 deletions.
32 changes: 17 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,30 +8,32 @@ Click [here](https://github.com/2004scape/Client2/tree/gh-pages) to view the cur

### Client

Try out the client hosted on Github!
Try out the client hosted on Github! It is 100% source ported and available to use.
Create your account on the 2004scape website.

| World | High Detail | Low Detail | Members |
|-----------------|--------------------------------------------------------------------------------|-------------------------------------------------------------------------------|---------|
| 1 (Central USA) | [Play Now!](https://2004scape.github.io/Client2/?world=1&detail=high&method=0) | [Play Now!](https://2004scape.github.io/Client2/?world=1&detail=low&method=0) | No |
| 2 (Central USA) | [Play Now!](https://2004scape.github.io/Client2/?world=2&detail=high&method=0) | [Play Now!](https://2004scape.github.io/Client2/?world=2&detail=low&method=0) | Yes |
| 3 (Germany) | [Play Now!](https://2004scape.github.io/Client2/?world=3&detail=high&method=0) | [Play Now!](https://2004scape.github.io/Client2/?world=3&detail=low&method=0) | Yes |
| 2 (Central USA) | [Play Now!](https://2004scape.github.io/Client2/?world=2&detail=high&method=0) | [Play Now!](https://2004scape.github.io/Client2/?world=2&detail=low&method=0) | Yes |
| 3 (Germany) | [Play Now!](https://2004scape.github.io/Client2/?world=3&detail=high&method=0) | [Play Now!](https://2004scape.github.io/Client2/?world=3&detail=low&method=0) | Yes |
| 4 (Germany) | [Play Now!](https://2004scape.github.io/Client2/?world=4&detail=high&method=0) | [Play Now!](https://2004scape.github.io/Client2/?world=4&detail=low&method=0) | No |

### Playground
### <a href="https://2004scape.github.io/Client2/playground" target="_blank">Playground</a> - An Interactive Model Viewer
### <a href="https://2004scape.github.io/Client2/items" target="_blank">Items Viewer</a> - View All the Items
### <a href="https://2004scape.github.io/Client2/mesanim" target="_blank">Message Animation Viewer</a> - A Chat Message Animation Editor
### <a href="https://2004scape.github.io/Client2/sounds" target="_blank">Sounds Viewer</a> - Sounds Viewer & Listener
### <a href="https://2004scape.github.io/Client2/viewer" target="_blank">Viewer</a> - A Cache Viewer (WIP)
### <a href="https://2004scape.github.io/Client2/interface-editor" target="_blank">Interface Editor</a> - An Interface Editor (WIP)

Testing code for an interactive model viewer. Code "playground."
---

https://2004scape.github.io/Client2/playground
## Commands

### Viewer
`::debug` Shows performance metrics (FPS, frame times).

Cache viewer.
`::fps` Set a targeted FPS (ex. `::fps 30`)

https://2004scape.github.io/Client2/viewer

### Items Viewer

https://2004scape.github.io/Client2/items
---

## First Time Installation

Expand All @@ -55,8 +57,8 @@ The client will automatically launch connecting to World 1.
Local world is hosted on World 0.
You have the ability to connect to live servers from the local client by changing the param.

http://localhost:8080/?world=0&detail=high&method=0
http://localhost:8080/?world=0&detail=high&method=0 (TypeScript)

This is not to be confused with the Java TeaVM client which is hosted here if the local server is running:

http://localhost/client?world=0&detail=high&method=0
http://localhost/client?world=0&detail=high&method=0 (Java)
1 change: 1 addition & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@
"webpack": "^5.90.0",
"webpack-bundle-analyzer": "^4.10.1",
"webpack-cli": "^5.1.4",
"webpack-dev-server": "^4.15.1"
"webpack-dev-server": "^4.15.1",
"terser-webpack-plugin": "^5.3.10"
},
"scripts": {
"build": "npm run asc && webpack --mode=production --node-env=production",
Expand Down
1 change: 1 addition & 0 deletions src/html/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Expires" content="0" />
<meta name="viewport" content="width=device-width, initial-scale = 0.86, maximum-scale=3.0, minimum-scale=0.86">

<link rel="icon" type="image/x-icon" href="favicon.ico">

Expand Down
21 changes: 20 additions & 1 deletion src/js/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ export abstract class Client extends GameShell {
// important client stuff
protected db: Database | null = null;
protected loopCycle: number = 0;
protected ingame: boolean = false;
protected archiveChecksums: number[] = [];
protected stream: ClientStream | null = null;
protected in: Packet = Packet.alloc(1);
Expand Down Expand Up @@ -654,6 +653,26 @@ export abstract class Client extends GameShell {
SeqFrame.instances = [];
};

getTitleScreenState(): number {
return this.titleScreenState;
}

isChatBackInputOpen(): boolean {
return this.chatbackInputOpen;
}

isShowSocialInput(): boolean {
return this.showSocialInput;
}

getChatInterfaceId(): number {
return this.chatInterfaceId;
}

getViewportInterfaceId(): number {
return this.viewportInterfaceId;
}

// ---- protected functions can be used by impl classes

protected unloadTitle = (): void => {
Expand Down
38 changes: 24 additions & 14 deletions src/js/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,35 +12,44 @@ type WorldList = {
};

export async function setupConfiguration(): Promise<void> {
const hostname: string = window.location.hostname;
const protocol: string = window.location.protocol;
const secured: boolean = protocol.startsWith('https');
await world();
detail();
method();
}

// setup the world config.
async function world(): Promise<void> {
if (GameShell.getParameter('world').length === 0) {
GameShell.setParameter('world', '1');
}

if (GameShell.getParameter('detail').length === 0) {
GameShell.setParameter('detail', 'high');
}

if (GameShell.getParameter('method').length === 0) {
GameShell.setParameter('method', '0');
}

if (hostname === 'localhost' && GameShell.getParameter('world') === '0') {
if (window.location.hostname === 'localhost' && GameShell.getParameter('world') === '0') {
localConfiguration();
} else {
await liveConfiguration(secured);
await liveConfiguration(window.location.protocol.startsWith('https'));
}
}

// setup the detail
function detail(): void {
if (GameShell.getParameter('detail').length === 0) {
GameShell.setParameter('detail', 'high');
}
if (GameShell.getParameter('detail') === 'low') {
Client.setLowMemory();
} else {
Client.setHighMemory();
}
}

// setup the method
function method(): void {
if (GameShell.getParameter('method').length === 0) {
GameShell.setParameter('method', '0');
}
}

// ---

function localConfiguration(): void {
Client.serverAddress = 'http://localhost';
Client.httpAddress = 'http://localhost';
Expand All @@ -61,6 +70,7 @@ async function liveConfiguration(secured: boolean): Promise<void> {
}
Client.portOffset = world.portOffset;
Client.members = world?.members === true;
GameShell.setParameter('world', world.id.toString(10));
}

async function getWorldInfo(secured: boolean, id: number, retries: number = 0): Promise<WorldList> {
Expand Down
Loading

0 comments on commit 269d04e

Please sign in to comment.