Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Synchronet
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Main
Synchronet
Commits
15203fc4
Commit
15203fc4
authored
13 years ago
by
mcmlxxix
Browse files
Options
Downloads
Patches
Plain Diff
make chat window control rely on chat and layout libraries, use frames for inputline and menu lines
parent
a580c7ca
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
xtrn/maze/game.js
+39
-50
39 additions, 50 deletions
xtrn/maze/game.js
xtrn/maze/menu.js
+12
-25
12 additions, 25 deletions
xtrn/maze/menu.js
with
51 additions
and
75 deletions
xtrn/maze/game.js
+
39
−
50
View file @
15203fc4
...
...
@@ -26,12 +26,11 @@ load(root + "menu.js");
var
settings
=
client
.
read
(
game_id
,
"
settings
"
,
1
);
var
status
=
{
WAITING
:
-
1
,
STARTING
:
0
,
RACING
:
1
,
FINISHED
:
2
};
var
frame
=
new
Frame
(
1
,
1
,
80
,
24
);
var
layout
=
new
Layout
(
frame
);
var
data
=
new
GameData
();
/* game splash screens */
function
splashStart
()
{
console
.
ctrlkey_passthru
=
"
+ACGKLOPQRT
U
VWXYZ
"
;
console
.
ctrlkey_passthru
=
"
+ACGKLOPQRTVWXYZ
"
;
bbs
.
sys_status
|=
SS_MOFF
;
bbs
.
sys_status
|=
SS_PAUSEOFF
;
console
.
clear
();
...
...
@@ -78,22 +77,14 @@ function lobby() {
/* display objects */
var
playerlist
=
new
Frame
(
59
,
5
,
20
,
18
,
BG_BLACK
,
frame
);
var
input
=
new
InputLine
(
3
,
console
.
screen_rows
-
1
,
54
,
150
);
var
input
=
new
InputLine
();
var
chat
=
new
JSONChat
(
user
.
number
,
undefined
,
serverAddr
,
serverPort
);
var
layout
=
new
Layout
(
frame
);
var
chat_window
=
layout
.
addView
(
"
chat
"
,
2
,
4
,
56
,
18
)
var
chat_tab
;
/* main menu */
var
menu
=
new
Menu
([
"
~Join race
"
,
"
~Leave race
"
,
"
~Ready
"
,
"
S~ettings
"
,
"
~Scores
"
,
"
~Chat
"
,
"
~Help
"
,
"
~Quit
"
],
3
,
23
,
54
,
"
\
1c
\
1h
"
,
"
\
1n
"
);
var
menu
=
new
Menu
([
"
~Join race
"
,
"
~Leave race
"
,
"
~Ready
"
,
"
S~ettings
"
,
"
~Scores
"
,
"
~Chat
"
,
"
~Help
"
,
"
~Quit
"
],
new
Frame
(
3
,
23
,
54
,
1
,
BG_BLACK
+
LIGHTGRAY
,
frame
),
"
\
1c
\
1h
"
,
"
\
1n
"
)
;
/* metadata */
var
profile
=
undefined
;
...
...
@@ -104,23 +95,36 @@ function lobby() {
frame
.
open
();
frame
.
load
(
root
+
"
lobby.bin
"
,
80
,
24
);
client
.
subscribe
(
game_id
,
"
games
"
);
chat
.
join
(
"
#mazerace
"
);
chat_window
.
show_title
=
false
;
chat_window
.
show_border
=
false
;
chat_tab
=
chat_window
.
addTab
(
"
#mazerace
"
);
data
.
who
();
chat
.
view
=
chat_window
;
chat
.
join
(
"
#mazerace
"
);
profile
=
data
.
profiles
[
user
.
alias
];
input
.
init
(
3
,
23
,
54
,
1
,
frame
);
menu
.
disable
(
"
L
"
);
menu
.
disable
(
"
R
"
);
profile
=
data
.
profiles
[
user
.
alias
];
layout
.
open
();
menu
.
frame
.
top
();
data
.
who
();
}
function
main
()
{
while
(
!
js
.
terminated
)
{
cycle
();
var
k
=
input
.
in
key
(
hotkeys
);
if
(
!
k
)
var
k
=
input
.
get
key
(
hotkeys
);
if
(
k
==
undefined
)
continue
;
if
(
hotkeys
)
{
k
=
k
.
toUpperCase
();
switch
(
k
)
{
case
KEY_LEFT
:
case
KEY_RIGHT
:
case
KEY_UP
:
case
KEY_DOWN
:
case
KEY_HOME
:
case
KEY_END
:
layout
.
getcmd
(
k
);
break
;
}
if
(
!
menu
.
items
[
k
]
||
!
menu
.
items
[
k
].
enabled
)
continue
;
switch
(
k
.
toUpperCase
())
{
...
...
@@ -141,21 +145,26 @@ function lobby() {
leaveMaze
();
break
;
case
"
E
"
:
chooseAvatar
();
chooseColor
();
todo
();
//chooseAvatar();
//chooseColor();
break
;
case
"
Q
"
:
return
;
case
"
C
"
:
input
.
d
ra
w
();
input
.
f
ra
me
.
top
();
hotkeys
=
false
;
break
;
}
}
else
{
chat
.
submit
(
chat_tab
.
title
.
toUpperCase
(),
k
);
menu
.
draw
();
hotkeys
=
true
;
if
(
k
.
length
>
0
)
{
layout
.
getcmd
(
k
);
}
else
{
menu
.
frame
.
top
();
hotkeys
=
true
;
}
}
}
}
...
...
@@ -165,10 +174,10 @@ function lobby() {
}
function
cycle
()
{
client
.
cycle
();
layout
.
cycle
();
chat
.
cycle
();
while
(
client
.
updates
.
length
>
0
)
processUpdate
(
client
.
updates
.
shift
());
chat
.
cycle
();
updateChatTab
();
if
(
frame
.
cycle
())
console
.
gotoxy
(
1
,
24
);
if
(
full_redraw
)
...
...
@@ -177,28 +186,10 @@ function lobby() {
listPlayers
();
data
.
updated
=
false
;
}
if
(
hotkeys
&&
menu
.
updated
)
{
menu
.
draw
();
menu
.
updated
=
false
;
}
if
(
readyToRace
())
{
data
.
mazes
[
gnum
]
=
client
.
read
(
game_id
,
"
mazes.
"
+
gnum
,
1
);
race
(
gnum
);
leaveMaze
();
full_redraw
=
true
;
}
}
function
updateChatTab
()
{
var
channel
=
chat
.
channels
[
chat_tab
.
title
.
toUpperCase
()];
while
(
channel
&&
channel
.
messages
.
length
>
0
)
{
var
msg
=
channel
.
messages
.
shift
();
var
str
=
""
;
if
(
msg
.
nick
)
var
str
=
getColor
(
chat
.
settings
.
NICK_COLOR
)
+
msg
.
nick
.
name
+
"
\
1n:
"
+
getColor
(
chat
.
settings
.
TEXT_COLOR
)
+
msg
.
str
;
else
var
str
=
getColor
(
chat
.
settings
.
NOTICE_COLOR
)
+
msg
.
str
;
chat_tab
.
getcmd
(
str
+
"
\r\n
"
);
}
}
function
getGameNumber
()
{
...
...
@@ -247,7 +238,6 @@ function lobby() {
}
}
function
chooseAvatar
()
{
todo
();
// var aFrame = new Frame(25,10,30,4,BG_BLUE,frame);
// aFrame.open();
// aFrame.crlf();
...
...
@@ -259,7 +249,6 @@ function lobby() {
// aFrame.delete();
}
function
chooseColor
()
{
todo
();
//var cf = new Frame(30,10,10,2,BG_BLACK);
}
function
todo
()
{
...
...
This diff is collapsed.
Click to expand it.
xtrn/maze/menu.js
+
12
−
25
View file @
15203fc4
function
Menu
(
items
,
x
,
y
,
w
,
hl
,
txt
)
{
function
Menu
(
items
,
frame
,
hk_color
,
text_color
)
{
this
.
items
=
[];
this
.
x
=
x
;
this
.
y
=
y
;
this
.
width
=
w
;
this
.
hl
=
hl
;
this
.
txt
=
txt
;
this
.
updated
=
true
;
this
.
frame
=
frame
;
this
.
hk_color
=
hk_color
;
this
.
text_color
=
text_color
;
this
.
disable
=
function
(
item
)
{
this
.
items
[
item
].
enabled
=
false
;
this
.
updated
=
true
;
this
.
draw
()
;
}
this
.
enable
=
function
(
item
)
{
this
.
items
[
item
].
enabled
=
true
;
this
.
updated
=
true
;
this
.
draw
()
;
}
this
.
add
=
function
(
items
)
{
for
(
i
=
0
;
i
<
items
.
length
;
i
++
)
{
hotkey
=
get_hotkey
(
items
[
i
]);
this
.
items
[
hotkey
.
toUpperCase
()]
=
new
Item
(
items
[
i
],
hotkey
,
h
l
,
txt
);
this
.
items
[
hotkey
.
toUpperCase
()]
=
new
Item
(
items
[
i
],
hotkey
,
h
k_color
,
t
e
xt
_color
);
}
}
this
.
clear
=
function
()
{
console
.
gotoxy
(
this
);
console
.
write
(
format
(
"
%*s
"
,
this
.
width
,
""
));
}
this
.
draw
=
function
()
{
var
str
=
""
;
for
each
(
var
i
in
this
.
items
)
{
for
each
(
var
i
in
this
.
items
)
if
(
i
.
enabled
==
true
)
str
+=
i
.
text
+
"
"
;
}
var
offset
=
str
.
length
-
console
.
strlen
(
strip_ctrl
(
str
));
console
.
gotoxy
(
this
);
console
.
attributes
=
ANSI_NORMAL
;
console
.
putmsg
(
format
(
"
%-*s
"
,
this
.
width
+
offset
,
str
));
this
.
updated
=
false
;
this
.
frame
.
clear
();
this
.
frame
.
putmsg
(
str
);
}
function
Item
(
item
,
hotkey
,
h
l
,
txt
)
function
Item
(
item
,
hotkey
,
h
k_color
,
t
e
xt
_color
)
{
this
.
enabled
=
true
;
this
.
hotkey
=
hotkey
;
this
.
text
=
item
.
replace
((
"
~
"
+
hotkey
)
,
h
l
+
hotkey
+
txt
);
this
.
text
=
item
.
replace
((
"
~
"
+
hotkey
)
,
h
k_color
+
hotkey
+
t
e
xt
_color
);
}
function
get_hotkey
(
item
)
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment