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
7f766fa8
Commit
7f766fa8
authored
16 years ago
by
mcmlxxix
Browse files
Options
Downloads
Patches
Plain Diff
removed unnecessary methods, modified display and initialization
parent
2f15b748
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
xtrn/chess/menu.js
+35
-58
35 additions, 58 deletions
xtrn/chess/menu.js
with
35 additions
and
58 deletions
xtrn/chess/menu.js
+
35
−
58
View file @
7f766fa8
function
Menu
(
title
,
x
,
y
,
color
,
hkey_color
)
{
//MENU CLASSES
this
.
title
=
title
;
//this.disabled=[];
//this.disabled_color="\1k\1h";
function
Menu
(
x
,
y
,
color
,
hkey_color
)
{
this
.
items
=
[];
var
orig_x
=
x
;
var
orig_y
=
y
;
this
.
color
=
color
;
this
.
hkey_color
=
hkey_color
;
this
.
x
=
x
;
this
.
y
=
y
;
this
.
showline
=
function
()
{
var
yyyy
=
orig_y
;
console
.
gotoxy
(
xxxx
,
yyyy
);
yyyy
++
;
console
.
cleartoeol
();
DrawLine
(
"
\
1w
\
1h
"
,
79
);
console
.
crlf
();
}
this
.
display
=
function
()
{
var
yyyy
=
orig_y
;
var
clear
=
5
;
var
cleared
=
0
;
for
(
i
in
this
.
items
)
{
if
(
this
.
items
[
i
].
enabled
)
{
console
.
gotoxy
(
orig_x
,
yyyy
);
yyyy
++
;
console
.
putmsg
(
this
.
items
[
i
].
text
);
console
.
cleartoeol
();
cleared
++
;
}
}
for
(
i
=
cleared
;
i
<
clear
;
i
++
)
{
console
.
gotoxy
(
orig_x
,
yyyy
);
yyyy
++
;
console
.
cleartoeol
();
}
}
this
.
disable
=
function
(
items
)
{
for
(
item
in
items
)
...
...
@@ -51,19 +20,19 @@ function Menu(title,x,y,color,hkey_color)
this
.
items
[
items
[
item
]].
enabled
=
true
;
}
}
this
.
getHotKey
=
function
(
item
)
{
var
keyindex
=
item
.
indexOf
(
"
~
"
)
+
1
;
return
(
item
.
charAt
(
keyindex
));
}
this
.
add
=
function
(
items
)
{
for
(
i
=
0
;
i
<
items
.
length
;
i
++
)
{
hotkey
=
this
.
getHotKey
(
items
[
i
]);
this
.
items
[
hotkey
.
toUpperCase
()]
=
new
MenuItem
(
items
[
i
],
hotkey
,
color
,
hkey_color
);
this
.
items
[
hotkey
.
toUpperCase
()].
Init
(
color
,
hkey_color
);
var
hotkey
=
this
.
getHotKey
(
items
[
i
]);
this
.
items
[
hotkey
.
toUpperCase
()]
=
new
MenuItem
(
items
[
i
],
this
.
color
,
hotkey
,
this
.
hkey_color
);
}
}
this
.
displayTitle
=
function
()
{
printf
(
"
\
1h
\
1w
"
+
this
.
title
);
}
this
.
countEnabled
=
function
()
{
var
items
=
[];
...
...
@@ -73,34 +42,42 @@ function Menu(title,x,y,color,hkey_color)
}
return
items
;
}
this
.
getHotKey
=
function
(
item
)
this
.
displayItems
=
function
()
{
keyindex
=
item
.
indexOf
(
"
~
"
)
+
1
;
return
item
.
charAt
(
keyindex
);
}
var
enabled
=
this
.
countEnabled
();
if
(
!
enabled
.
length
)
return
false
;
console
.
gotoxy
(
this
.
x
,
this
.
y
);
for
(
e
=
0
;
e
<
enabled
.
length
;
e
++
)
{
console
.
putmsg
(
this
.
items
[
enabled
[
e
]].
text
);
if
(
e
<
enabled
.
length
-
1
)
write
(
console
.
ansi
(
ANSI_NORMAL
)
+
"
"
);
}
}
this
.
displayHorizontal
=
function
()
{
var
enabled
=
this
.
countEnabled
();
if
(
!
enabled
.
length
)
return
false
;
ClearLine
(
1
,
48
);
console
.
gotoxy
(
orig_x
,
orig_y
);
console
.
gotoxy
(
this
.
x
,
this
.
y
);
console
.
putmsg
(
this
.
color
+
"
[
"
);
for
(
e
=
0
;
e
<
enabled
.
length
;
e
++
)
{
console
.
putmsg
(
this
.
items
[
enabled
[
e
]].
text
);
if
(
e
<
enabled
.
length
-
1
)
write
(
"
"
);
console
.
putmsg
(
this
.
hkey_color
+
this
.
items
[
enabled
[
e
]].
hotkey
.
toUpperCase
()
);
if
(
e
<
enabled
.
length
-
1
)
console
.
putmsg
(
this
.
color
+
"
,
"
);
}
console
.
putmsg
(
this
.
color
+
"
]
"
);
}
}
function
MenuItem
(
item
,
hotkey
,
color
,
hkey_color
)
{
//MENU ITEM OBJECT
function
MenuItem
(
item
,
color
,
hotkey
,
hkey_color
)
{
this
.
item
=
item
;
this
.
displayColor
=
color
;
this
.
keyColor
=
hkey_color
;
this
.
item
=
item
;
this
.
hotkey
=
hotkey
;
this
.
enabled
=
true
;
this
.
hotkey
=
hotkey
;
this
.
Init
=
function
(
color
,
hkey_color
)
this
.
Init
=
function
()
{
this
.
text
=
this
.
item
.
replace
((
"
~
"
+
hotkey
)
,
(
h
key
_c
olor
+
hotkey
+
c
olor
));
this
.
text
=
this
.
item
.
replace
((
"
~
"
+
this
.
hotkey
)
,
(
this
.
key
C
olor
+
this
.
hotkey
+
this
.
displayC
olor
));
}
this
.
Init
();
}
\ No newline at end of file
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