move unmaintained files into outdated folder
If an old port is resurrected to work with current version code, its files can be relocated to the appropriate sys or win folder as required. In the meantime, the burden of upkeep can be avoided for the stuff in the outdated folder for now.
This commit is contained in:
4
outdated/win/Qt3/.gitattributes
vendored
Normal file
4
outdated/win/Qt3/.gitattributes
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
Install.Qt NHSUBST
|
||||
qpe-nethack.control NH_header=no
|
||||
knethack.lnk NH_header=no
|
||||
* NH_filestag=(file%s_for_the_Qt_3_widget_library_-_X11,_Windows,_Mac_OS_X,_or_Qtopia)
|
||||
20
outdated/win/Qt3/Info.plist
Normal file
20
outdated/win/Qt3/Info.plist
Normal file
@@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleGetInfoHTML</key>
|
||||
<string>http://www.nethack.org</string>
|
||||
<key>CFBundleGetInfoString</key>
|
||||
<string>Copyright (C) 1985-2003 Stichting Mathematisch Centrum</string>
|
||||
<key>CFBundleIconFile</key>
|
||||
<string>nethack.icns</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>org.nethack.qt</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>APPL</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>3.5.0</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>NHak</string>
|
||||
</dict>
|
||||
</plist>
|
||||
113
outdated/win/Qt3/Install.Qt
Normal file
113
outdated/win/Qt3/Install.Qt
Normal file
@@ -0,0 +1,113 @@
|
||||
Installing NetHack with a Qt or KDE interface
|
||||
---------------------------------------------
|
||||
$NHDT-Date: 1524689332 2018/04/25 20:48:52 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.11 $
|
||||
# Copyright (c) 2004 by Warwick Allison
|
||||
# NetHack may be freely redistributed. See license for details.
|
||||
|
||||
This document describes the installation of NetHack with a Qt interface
|
||||
on UNIX/X11 or Mac OS X. This code should also work with Qt/Windows, but
|
||||
support for that is not currently official.
|
||||
|
||||
You can download Qt from http://www.trolltech.com.
|
||||
You need Qt 2.0 or later to use this code.
|
||||
|
||||
To use this code on UNIX (not Mac OS X):
|
||||
|
||||
1. follow the directions for the UNIX installation (in ../../sys/unix)
|
||||
to create the Makefiles.
|
||||
|
||||
2. ../../include/config.h
|
||||
|
||||
define QT_GRAPHICS (search for it). You can comment out
|
||||
TTY_GRAPHICS if you want to, or leave it in to support both
|
||||
interfaces (in which case be sure you have the right curses
|
||||
libraries etc. required for that interface).
|
||||
|
||||
3. ../../src/Makefile
|
||||
|
||||
ensure your QTDIR environment variable was set correctly when
|
||||
you installed Qt - $QTDIR/include/qwidget.h should exist, for
|
||||
example.
|
||||
|
||||
ensure CXX and LINK are set to the compiler and linker you need
|
||||
for compiling and linking C++ software (e.g., set both to g++).
|
||||
|
||||
add $(WINQTSRC), $(WINQTOBJ), and $(WINQTLIB) to WINSRC, WINOBJ,
|
||||
and WINLIB respectively, and compile. This will give you an
|
||||
executable supporting both Qt and tty windowing.
|
||||
|
||||
4. ../../Makefile (the top-level makefile)
|
||||
|
||||
Just change the VARDATND setting to contain the files
|
||||
"x11tiles", "rip.xpm", and "nhsplash.xpm":
|
||||
|
||||
VARDATND = x11tiles rip.xpm nhsplash.xpm
|
||||
|
||||
5. Follow all the instructions in ../../sys/unix/Install.unx for
|
||||
the remainder of the installation process.
|
||||
|
||||
6. Consider adding the lines below to your .nethackrc, as they are
|
||||
likely to give the best interface for this window port:
|
||||
|
||||
OPTIONS=name:player,number_pad,menustyle:partial,!time,showexp
|
||||
OPTIONS=hilite_pet,toptenwin,msghistory:200,windowtype:Qt
|
||||
|
||||
If you are using KDE, you may want to also try the KDE version. It just
|
||||
uses the KDE menubar and follows other KDE conventions - there is no
|
||||
extra functionality. To do so:
|
||||
|
||||
1. Ensure that you have KDE 2.x libraries on your system
|
||||
(in 1999 KDE 1.x was the norm)
|
||||
|
||||
2. ../../src/Makefile
|
||||
|
||||
Add $(KDECXXFLAGS) to the CXXFLAGS definition, $(KDELFLAGS) to
|
||||
the LFLAGS definition and $(WINKDELIB) to WINLIB.
|
||||
|
||||
3. Some additional files here - knh-mini.xpm, knh.xpm, and
|
||||
knethack.lnk are useful if you want to install "knethack" in
|
||||
the KDE games directory.
|
||||
|
||||
If you are using Qtopia, you can compile NetHack for that environment
|
||||
with the following additional steps:
|
||||
|
||||
1. First be sure that you can build a simple Qtopia application,
|
||||
such as the examples that ship with Qtopia. Do not attempt
|
||||
something as challenging to compile as NetHack before you can
|
||||
already build a Qtopia application for your target device.
|
||||
|
||||
2. If you are cross-compiling (eg. targetting an ARM-based handheld),
|
||||
be sure to follow the steps for cross-compiling in the Makefile.src
|
||||
and Makefile.utl files.
|
||||
|
||||
3. To CXXFLAGS in Makefile.src, add:
|
||||
-DQWS -I$(QPEDIR)/include -fno-rtti -fno-exceptions
|
||||
|
||||
4. Rather than -lqt in WINQTLIB, have:
|
||||
-L$(QPEDIR)/lib -lqpe -lqte
|
||||
|
||||
5. After building, use the "mkipks" program that ships with Qtopia
|
||||
to package the result into an ipk file.
|
||||
|
||||
To use this code on Mac OS X:
|
||||
|
||||
1. follow the directions for the UNIX installation (in ../../sys/unix)
|
||||
to create the Makefiles.
|
||||
|
||||
2. quite a number of changes are required to the Makefiles. They are
|
||||
slowly being made 'official', but for now they are all in the patch
|
||||
nethack-macosx-qt.patch:
|
||||
|
||||
cd ../..
|
||||
patch -p0 < win/Qt/nethack-macosx-qt.patch
|
||||
|
||||
3. Follow all the instructions in ../../sys/unix/Install.unx for
|
||||
the remainder of the installation process (basically run "make install").
|
||||
|
||||
4. Consider adding the lines below to a file called "NetHack Defaults",
|
||||
in your "Library/Preferences" folder, as they are likely to give
|
||||
the best interface for this window port:
|
||||
|
||||
OPTIONS=name:player,number_pad,menustyle:partial,!time,showexp
|
||||
OPTIONS=hilite_pet,toptenwin,msghistory:200,windowtype:Qt
|
||||
|
||||
18
outdated/win/Qt3/knethack.lnk
Normal file
18
outdated/win/Qt3/knethack.lnk
Normal file
@@ -0,0 +1,18 @@
|
||||
# KDE Config File
|
||||
# Call this file knethack.kdelnk or knethack.desktop
|
||||
[KDE Desktop Entry]
|
||||
Name=Nethack
|
||||
Name[fr]=Nethack
|
||||
Name[hu]=Nethack
|
||||
Name[no]=Nethack
|
||||
Name[sk]=Nethack
|
||||
Name[cs]=Nethack
|
||||
Name[hr]=Nethack
|
||||
Name[pt]=Nethack
|
||||
Name[pt_BR]=Nethack
|
||||
Icon=knh.xpm
|
||||
Exec=knethack -caption "%c" %i %m
|
||||
Type=Application
|
||||
DocPath=knethack/index.html
|
||||
Comment=The classic Unix role-playing game - fight monsters and seek the Amulet of Yendor for your god!
|
||||
|
||||
30
outdated/win/Qt3/knh-mini.xpm
Normal file
30
outdated/win/Qt3/knh-mini.xpm
Normal file
@@ -0,0 +1,30 @@
|
||||
/* XPM */
|
||||
static char *noname[] = {
|
||||
/* width height ncolors chars_per_pixel */
|
||||
"16 16 7 1",
|
||||
/* colors */
|
||||
" c #000000",
|
||||
". c #DCDCDC",
|
||||
"X c #008080",
|
||||
"o c #A0A0A0",
|
||||
"O c None",
|
||||
"+ c #FFFFFF",
|
||||
"@ c #C3C3C3",
|
||||
/* pixels */
|
||||
"OOOOOOOOOOOOOOOO",
|
||||
"OOO+O+++@@@O@OOO",
|
||||
"O+O+++++@@@@@O.O",
|
||||
"O+o+XXXXX X @ . ",
|
||||
"O+o+XXXX X X@ . ",
|
||||
"OO +XXXXX X @ O ",
|
||||
"OOO+XXXX X X@ OO",
|
||||
"OOO+XXXXX X @ OO",
|
||||
"OOO+XXXX X X@ OO",
|
||||
"OOOO+XXXX X@ OO",
|
||||
"OOOO+XXX X . OO",
|
||||
"OOO+O+XXX . . OO",
|
||||
"OO+++ +X . ... O",
|
||||
"O+++. O+. .... ",
|
||||
"OO+. OOOOOO.. O",
|
||||
"OOOOOOOOOOOOOOOO"
|
||||
};
|
||||
67
outdated/win/Qt3/knh.xpm
Normal file
67
outdated/win/Qt3/knh.xpm
Normal file
@@ -0,0 +1,67 @@
|
||||
/* XPM */
|
||||
static char *noname[] = {
|
||||
/* width height ncolors chars_per_pixel */
|
||||
"40 40 20 1",
|
||||
/* colors */
|
||||
" c #000000",
|
||||
". c #0000C0",
|
||||
"X c #FFC0FF",
|
||||
"o c #FFC0C0",
|
||||
"O c #DCDCDC",
|
||||
"+ c #C0C0FF",
|
||||
"@ c #008080",
|
||||
"# c #A0A0A0",
|
||||
"$ c None",
|
||||
"% c #000080",
|
||||
"& c #585858",
|
||||
"* c #800080",
|
||||
"= c #FFFFFF",
|
||||
"- c #FFFFC0",
|
||||
"; c #00C0C0",
|
||||
": c #C0FFFF",
|
||||
"> c #C0FFC0",
|
||||
", c #C3C3C3",
|
||||
"< c #FFDCA8",
|
||||
"1 c #0000FF",
|
||||
/* pixels */
|
||||
"$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$",
|
||||
"$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$",
|
||||
"$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$",
|
||||
"$$$$$$$$=$$$$$$=,==<,=<,$$$$$$,$$$$$$$$$",
|
||||
"$$$$$$$$==$$$=====,=<>,<><$$$<>$$$$$$$$$",
|
||||
"$$$$$$$$===$====,==>,=<,<,,$,,<$$$$$$$$$",
|
||||
"$$$==$$$==========<=<,><,><<><,$$$,<$$$$",
|
||||
"$$$====$========,==,,=<>,<,>,<,$<><,$$$$",
|
||||
"$$$====$==========<=<,,<<><,<><$,,<>$$$$",
|
||||
"$$$$#&&&==$#$#$#@#$&@#&&@&&&&,, && $$",
|
||||
"$$$;#@&@==;#;#;#$;&#@&@$&@&@$>< &@ $$",
|
||||
"$$$====&==###1##.##@&#&@&&$&&<, <>O< $$",
|
||||
"$$$====&==$;##;##;&#@&@$&@&@&>, O<,> $$",
|
||||
"$$$==&@&==#1#;##.##@&#&@&$@$&,< ,< $$",
|
||||
"$$$$ ==###1#;##.#@$&&&@&&@-, $ $$",
|
||||
"$$$$$ =X;#;###&;#&@#&@$&@$&,< $$ $$$",
|
||||
"$$$$$$ ==#$+@+1##@#&@&$@&&&@<> $$$$$$",
|
||||
"$$$$$$$$=X;#1#$#@##@&#@&&&@$&<, $$$$$$",
|
||||
"$$$$$$$$==##;#;##1$#@&$@$&&@&>< $$$$$$",
|
||||
"$$$$$$$$=X;###1#@##@&#@&&@$&&O, $$$$$$",
|
||||
"$$$$$$$$==#1#;##;#.#@&&$@&@&@<> $$$$$$",
|
||||
"$$$$$$$$$==###;#*;#&@#&@&&$&O< $$$$$$$",
|
||||
"$$$$$$$$$==;#1,$;#&#@$@&$@&@<, $$$$$$$",
|
||||
"$$$$$$$$$$=X####.##@&#&&@&&<O $$$$$$$$",
|
||||
"$$$$$$$$$$==;#;##;*#@&@$&&@O< $$$$$$$",
|
||||
"$$$$$$$$==$==1##.#;&@+&&@&O< <, $$$$$$",
|
||||
"$$$$$$$===#:=#;###&+%&@$&O> ><, $$$$$$",
|
||||
"$$$$$$====@&=O##@#;&@#&&,< <,>< $$$$$",
|
||||
"$$$$$===#$== ==$1#&#&@&O> ,<$#,,> $$$$",
|
||||
"$$$$===#;#== ==$#;&@#O, >,#;&<,< $$$$",
|
||||
"$$$==$#;*@O< ====Oo,> <,&$#@&O, $$$",
|
||||
"$$$==;$#&&<, $===<,< <O@&;#&>< $$",
|
||||
"$$$==##;&O>, $$==,> $$ ,<&&#$@o, $$",
|
||||
"$$$===X=O,< $$$$$$$$$$$$$>OO,Oo> $$$",
|
||||
"$$$$====,< $$$$$$$$$$$$$$,<,>,<, $$$$",
|
||||
"$$$$$===<> $$$$$$$$$$$$$$$$><,<> $$$$",
|
||||
"$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$",
|
||||
"$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$",
|
||||
"$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$",
|
||||
"$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$"
|
||||
};
|
||||
9
outdated/win/Qt3/qpe-nethack.control
Normal file
9
outdated/win/Qt3/qpe-nethack.control
Normal file
@@ -0,0 +1,9 @@
|
||||
Files: bin/nethack pics/NetHack.png apps/Games/nethack.desktop games/lib/nethackdir/[a-r]* games/lib/nethackdir/[t-z]* games/lib/nethackdir/save games/lib/nethackdir/s*.* games/lib/nethackdir/[A-Z0-9]*
|
||||
Priority: optional
|
||||
Section: qpe/games
|
||||
Maintainer: Warwick Allison <warwick@trolltech.com>
|
||||
Architecture: arm
|
||||
Version: 3.5.0-1
|
||||
Depends: qpe-base ($QPE_VERSION)
|
||||
Description: NetHack - The Dungeon Game
|
||||
Graphical version of NetHack for Qtopia
|
||||
168
outdated/win/Qt3/qt3_clust.cpp
Normal file
168
outdated/win/Qt3/qt3_clust.cpp
Normal file
@@ -0,0 +1,168 @@
|
||||
/* NetHack 3.6 qt_clust.cpp $NHDT-Date: 1575917719 2019/12/09 18:55:19 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.0 $ */
|
||||
/* Copyright (c) Warwick Allison, 1999. */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
#include "qt3_clust.h"
|
||||
|
||||
static
|
||||
void include(QRect& r, const QRect& rect)
|
||||
{
|
||||
if (rect.left()<r.left()) {
|
||||
r.setLeft(rect.left());
|
||||
}
|
||||
if (rect.right()>r.right()) {
|
||||
r.setRight(rect.right());
|
||||
}
|
||||
if (rect.top()<r.top()) {
|
||||
r.setTop(rect.top());
|
||||
}
|
||||
if (rect.bottom()>r.bottom()) {
|
||||
r.setBottom(rect.bottom());
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
A Clusterizer groups rectangles (QRects) into non-overlapping rectangles
|
||||
by a merging heuristic.
|
||||
*/
|
||||
Clusterizer::Clusterizer(int maxclusters) :
|
||||
cluster(new QRect[maxclusters]),
|
||||
count(0),
|
||||
max(maxclusters)
|
||||
{ }
|
||||
|
||||
Clusterizer::~Clusterizer()
|
||||
{
|
||||
delete [] cluster;
|
||||
}
|
||||
|
||||
void Clusterizer::clear()
|
||||
{
|
||||
count=0;
|
||||
}
|
||||
|
||||
void Clusterizer::add(int x, int y)
|
||||
{
|
||||
add(QRect(x,y,1,1));
|
||||
}
|
||||
|
||||
void Clusterizer::add(int x, int y, int w, int h)
|
||||
{
|
||||
add(QRect(x,y,w,h));
|
||||
}
|
||||
|
||||
void Clusterizer::add(const QRect& rect)
|
||||
{
|
||||
QRect biggerrect(rect.x()-1,rect.y()-1,rect.width()+2,rect.height()+2);
|
||||
|
||||
//assert(rect.width()>0 && rect.height()>0);
|
||||
|
||||
int cursor;
|
||||
|
||||
for (cursor=0; cursor<count; cursor++) {
|
||||
if (cluster[cursor].contains(rect)) {
|
||||
// Wholly contained already.
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
int lowestcost=9999999;
|
||||
int cheapest=-1;
|
||||
for (cursor=0; cursor<count; cursor++) {
|
||||
if (cluster[cursor].intersects(biggerrect)) {
|
||||
QRect larger=cluster[cursor];
|
||||
include(larger,rect);
|
||||
int cost=larger.width()*larger.height()
|
||||
- cluster[cursor].width()*cluster[cursor].height();
|
||||
|
||||
if (cost < lowestcost) {
|
||||
bool bad=FALSE;
|
||||
for (int c=0; c<count && !bad; c++) {
|
||||
bad=cluster[c].intersects(larger) && c!=cursor;
|
||||
}
|
||||
if (!bad) {
|
||||
cheapest=cursor;
|
||||
lowestcost=cost;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (cheapest>=0) {
|
||||
include(cluster[cheapest],rect);
|
||||
return;
|
||||
}
|
||||
|
||||
if (count < max) {
|
||||
cluster[count++]=rect;
|
||||
return;
|
||||
}
|
||||
|
||||
// Do cheapest of:
|
||||
// add to closest cluster
|
||||
// do cheapest cluster merge, add to new cluster
|
||||
|
||||
lowestcost=9999999;
|
||||
cheapest=-1;
|
||||
for (cursor=0; cursor<count; cursor++) {
|
||||
QRect larger=cluster[cursor];
|
||||
include(larger,rect);
|
||||
int cost=larger.width()*larger.height()
|
||||
- cluster[cursor].width()*cluster[cursor].height();
|
||||
if (cost < lowestcost) {
|
||||
bool bad=FALSE;
|
||||
for (int c=0; c<count && !bad; c++) {
|
||||
bad=cluster[c].intersects(larger) && c!=cursor;
|
||||
}
|
||||
if (!bad) {
|
||||
cheapest=cursor;
|
||||
lowestcost=cost;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// XXX could make an heuristic guess as to whether we
|
||||
// XXX need to bother looking for a cheap merge.
|
||||
|
||||
int cheapestmerge1=-1;
|
||||
int cheapestmerge2=-1;
|
||||
|
||||
for (int merge1=0; merge1<count; merge1++) {
|
||||
for (int merge2=0; merge2<count; merge2++) {
|
||||
if (merge1!=merge2) {
|
||||
QRect larger=cluster[merge1];
|
||||
include(larger,cluster[merge2]);
|
||||
int cost=larger.width()*larger.height()
|
||||
- cluster[merge1].width()*cluster[merge1].height()
|
||||
- cluster[merge2].width()*cluster[merge2].height();
|
||||
if (cost < lowestcost) {
|
||||
bool bad=FALSE;
|
||||
for (int c=0; c<count && !bad; c++) {
|
||||
bad=cluster[c].intersects(larger) && c!=cursor;
|
||||
}
|
||||
if (!bad) {
|
||||
cheapestmerge1=merge1;
|
||||
cheapestmerge2=merge2;
|
||||
lowestcost=cost;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (cheapestmerge1>=0) {
|
||||
include(cluster[cheapestmerge1],cluster[cheapestmerge2]);
|
||||
cluster[cheapestmerge2]=cluster[count--];
|
||||
} else {
|
||||
// if (!cheapest) debugRectangles(rect);
|
||||
include(cluster[cheapest],rect);
|
||||
}
|
||||
|
||||
// NB: clusters do not intersect (or intersection will
|
||||
// overwrite). This is a result of the above algorithm,
|
||||
// given the assumption that (x,y) are ordered topleft
|
||||
// to bottomright.
|
||||
}
|
||||
|
||||
const QRect& Clusterizer::operator[](int i)
|
||||
{
|
||||
return cluster[i];
|
||||
}
|
||||
34
outdated/win/Qt3/qt3_clust.h
Normal file
34
outdated/win/Qt3/qt3_clust.h
Normal file
@@ -0,0 +1,34 @@
|
||||
/* NetHack 3.6 qt_clust.h $NHDT-Date: 1432512779 2015/05/25 00:12:59 $ $NHDT-Branch: master $:$NHDT-Revision: 1.8 $ */
|
||||
/* Copyright (c) Warwick Allison, 1999. */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
|
||||
#ifndef clusterizer_H
|
||||
#define clusterizer_H
|
||||
|
||||
#include <qrect.h>
|
||||
|
||||
class Clusterizer
|
||||
{
|
||||
public:
|
||||
Clusterizer(int maxclusters);
|
||||
~Clusterizer();
|
||||
|
||||
void add(int x, int y); // 1x1 rectangle (point)
|
||||
void add(int x, int y, int w, int h);
|
||||
void add(const QRect &rect);
|
||||
|
||||
void clear();
|
||||
int
|
||||
clusters()
|
||||
{
|
||||
return count;
|
||||
}
|
||||
const QRect &operator[](int i);
|
||||
|
||||
private:
|
||||
QRect *cluster;
|
||||
int count;
|
||||
const int max;
|
||||
};
|
||||
|
||||
#endif
|
||||
11
outdated/win/Qt3/qt3_kde0.h
Normal file
11
outdated/win/Qt3/qt3_kde0.h
Normal file
@@ -0,0 +1,11 @@
|
||||
/* NetHack 3.6 qt_kde0.h $NHDT-Date: 1432512779 2015/05/25 00:12:59 $ $NHDT-Branch: master $:$NHDT-Revision: 1.8 $ */
|
||||
/* Copyright (c) Warwick Allison, 1999. */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
|
||||
#ifndef QT_DUMMYKDE
|
||||
#define QT_DUMMYKDE
|
||||
class KTopLevelWidget : public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
};
|
||||
#endif
|
||||
5315
outdated/win/Qt3/qt3_win.cpp
Normal file
5315
outdated/win/Qt3/qt3_win.cpp
Normal file
File diff suppressed because it is too large
Load Diff
890
outdated/win/Qt3/qt3_win.h
Normal file
890
outdated/win/Qt3/qt3_win.h
Normal file
@@ -0,0 +1,890 @@
|
||||
// NetHack 3.6 qt_win.h $NHDT-Date: 1575917700 2019/12/09 18:55:00 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.0 $
|
||||
// Copyright (c) Warwick Allison, 1999.
|
||||
// NetHack may be freely redistributed. See license for details.
|
||||
//
|
||||
// Qt Binding for NetHack 3.4
|
||||
//
|
||||
// Unfortunately, this doesn't use Qt as well as I would like,
|
||||
// primarily because NetHack is fundamentally a getkey-type
|
||||
// program rather than being event driven (hence the ugly key
|
||||
// and click buffer rather), but also because this is my first
|
||||
// major application of Qt.
|
||||
//
|
||||
|
||||
#ifndef qt_win_h
|
||||
#define qt_win_h
|
||||
|
||||
#define QT_CLEAN_NAMESPACE
|
||||
|
||||
#include <qdialog.h>
|
||||
#include <qpushbutton.h>
|
||||
#include <qbuttongroup.h>
|
||||
#include <qlabel.h>
|
||||
#include <qlineedit.h>
|
||||
#if defined(QWS)
|
||||
#include <qpe/qpeapplication.h>
|
||||
#else
|
||||
#include <qapplication.h>
|
||||
#endif
|
||||
#include <qspinbox.h>
|
||||
#include <qcheckbox.h>
|
||||
#include <qfile.h>
|
||||
#include <qlistbox.h>
|
||||
#include <qlistview.h>
|
||||
#include <qmessagebox.h>
|
||||
#include <qpixmap.h>
|
||||
#include <qimage.h>
|
||||
#include <qarray.h>
|
||||
#include <qcombobox.h>
|
||||
#include <qscrollview.h>
|
||||
#if QT_VERSION >= 300
|
||||
#include <qttableview.h>
|
||||
// Should stop using QTableView
|
||||
#define QTableView QtTableView
|
||||
#else
|
||||
#include <qtableview.h>
|
||||
#endif
|
||||
#include <qmainwindow.h>
|
||||
#include <qwidgetstack.h>
|
||||
|
||||
#ifdef KDE
|
||||
#include <kapp.h>
|
||||
#include <ktopwidget.h>
|
||||
#endif
|
||||
|
||||
#include "qt3_clust.h"
|
||||
|
||||
class QVBox;
|
||||
class QMenuBar;
|
||||
class QRadioButton;
|
||||
class NhPSListView;
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
//
|
||||
// The beautiful, abstracted and well-modelled classes...
|
||||
//
|
||||
//////////////////////////////////////////////////////////////
|
||||
|
||||
class NetHackQtGlyphs;
|
||||
|
||||
class NetHackQtLineEdit : public QLineEdit
|
||||
{
|
||||
public:
|
||||
NetHackQtLineEdit();
|
||||
NetHackQtLineEdit(QWidget *parent, const char *name);
|
||||
|
||||
void fakeEvent(int key, int ascii, int state);
|
||||
};
|
||||
|
||||
class NetHackQtSettings : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
// Size of window - used to decide default sizes
|
||||
NetHackQtSettings(int width, int height);
|
||||
|
||||
NetHackQtGlyphs &glyphs();
|
||||
const QFont &normalFont();
|
||||
const QFont &normalFixedFont();
|
||||
const QFont &largeFont();
|
||||
|
||||
bool ynInMessages();
|
||||
|
||||
signals:
|
||||
void fontChanged();
|
||||
void tilesChanged();
|
||||
|
||||
public slots:
|
||||
void toggleGlyphSize();
|
||||
void setGlyphSize(bool);
|
||||
|
||||
private:
|
||||
QSpinBox tilewidth;
|
||||
QSpinBox tileheight;
|
||||
QLabel widthlbl;
|
||||
QLabel heightlbl;
|
||||
QCheckBox whichsize;
|
||||
QSize othersize;
|
||||
|
||||
QComboBox fontsize;
|
||||
|
||||
QFont normal, normalfixed, large;
|
||||
|
||||
NetHackQtGlyphs *theglyphs;
|
||||
|
||||
private slots:
|
||||
void resizeTiles();
|
||||
};
|
||||
|
||||
class NetHackQtKeyBuffer
|
||||
{
|
||||
public:
|
||||
NetHackQtKeyBuffer();
|
||||
|
||||
bool Empty() const;
|
||||
bool Full() const;
|
||||
|
||||
void Put(int k, int ascii, int state);
|
||||
void Put(char a);
|
||||
void Put(const char *str);
|
||||
int GetKey();
|
||||
int GetAscii();
|
||||
int GetState();
|
||||
|
||||
int TopKey() const;
|
||||
int TopAscii() const;
|
||||
int TopState() const;
|
||||
|
||||
private:
|
||||
enum { maxkey = 64 };
|
||||
int key[maxkey];
|
||||
int ascii[maxkey];
|
||||
int state[maxkey];
|
||||
int in, out;
|
||||
};
|
||||
|
||||
class NetHackQtClickBuffer
|
||||
{
|
||||
public:
|
||||
NetHackQtClickBuffer();
|
||||
|
||||
bool Empty() const;
|
||||
bool Full() const;
|
||||
|
||||
void Put(int x, int y, int mod);
|
||||
|
||||
int NextX() const;
|
||||
int NextY() const;
|
||||
int NextMod() const;
|
||||
|
||||
void Get();
|
||||
|
||||
private:
|
||||
enum { maxclick = 64 };
|
||||
struct ClickRec {
|
||||
int x, y, mod;
|
||||
} click[maxclick];
|
||||
int in, out;
|
||||
};
|
||||
|
||||
class NetHackQtSavedGameSelector : public QDialog
|
||||
{
|
||||
public:
|
||||
NetHackQtSavedGameSelector(const char **saved);
|
||||
|
||||
int choose();
|
||||
};
|
||||
|
||||
class NetHackQtPlayerSelector : private QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum { R_None = -1, R_Quit = -2, R_Rand = -3 };
|
||||
|
||||
NetHackQtPlayerSelector(NetHackQtKeyBuffer &);
|
||||
|
||||
protected:
|
||||
virtual void done(int);
|
||||
|
||||
public slots:
|
||||
void Quit();
|
||||
void Random();
|
||||
|
||||
void selectName(const QString &n);
|
||||
void selectRole();
|
||||
void selectRace();
|
||||
void setupOthers();
|
||||
void selectGender(int);
|
||||
void selectAlignment(int);
|
||||
|
||||
public:
|
||||
bool Choose();
|
||||
|
||||
private:
|
||||
NetHackQtKeyBuffer &keysource;
|
||||
NhPSListView *role;
|
||||
NhPSListView *race;
|
||||
QRadioButton **gender;
|
||||
QRadioButton **alignment;
|
||||
bool fully_specified_role;
|
||||
};
|
||||
|
||||
class NetHackQtStringRequestor : QDialog
|
||||
{
|
||||
private:
|
||||
QLabel prompt;
|
||||
NetHackQtLineEdit input;
|
||||
QPushButton *okay;
|
||||
QPushButton *cancel;
|
||||
NetHackQtKeyBuffer &keysource;
|
||||
|
||||
virtual void done(int);
|
||||
|
||||
public:
|
||||
NetHackQtStringRequestor(NetHackQtKeyBuffer &, const char *p,
|
||||
const char *cancelstr = "Cancel");
|
||||
void SetDefault(const char *);
|
||||
bool Get(char *buffer, int maxchar = 80);
|
||||
virtual void resizeEvent(QResizeEvent *);
|
||||
};
|
||||
|
||||
class NetHackQtExtCmdRequestor : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
NetHackQtKeyBuffer &keysource;
|
||||
|
||||
public:
|
||||
NetHackQtExtCmdRequestor(NetHackQtKeyBuffer &ks);
|
||||
int get();
|
||||
|
||||
private slots:
|
||||
void cancel();
|
||||
void done(int i);
|
||||
};
|
||||
|
||||
class NetHackQtWindow
|
||||
{
|
||||
public:
|
||||
NetHackQtWindow();
|
||||
virtual ~NetHackQtWindow();
|
||||
|
||||
virtual QWidget *Widget() = 0;
|
||||
|
||||
virtual void Clear();
|
||||
virtual void Display(bool block);
|
||||
virtual bool Destroy();
|
||||
virtual void CursorTo(int x, int y);
|
||||
virtual void PutStr(int attr, const char *text);
|
||||
virtual void StartMenu();
|
||||
virtual void AddMenu(int glyph, const ANY_P *identifier, char ch,
|
||||
char gch, int attr, const char *str, unsigned itemflags);
|
||||
virtual void EndMenu(const char *prompt);
|
||||
virtual int SelectMenu(int how, MENU_ITEM_P **menu_list);
|
||||
virtual void ClipAround(int x, int y);
|
||||
virtual void PrintGlyph(int x, int y, int glyph);
|
||||
virtual void UseRIP(int how, time_t when);
|
||||
|
||||
int nhid;
|
||||
};
|
||||
|
||||
class NetHackQtGlyphs
|
||||
{
|
||||
public:
|
||||
NetHackQtGlyphs();
|
||||
|
||||
int
|
||||
width() const
|
||||
{
|
||||
return size.width();
|
||||
}
|
||||
int
|
||||
height() const
|
||||
{
|
||||
return size.height();
|
||||
}
|
||||
void toggleSize();
|
||||
void setSize(int w, int h);
|
||||
|
||||
void drawGlyph(QPainter &, int glyph, int pixelx, int pixely);
|
||||
void drawCell(QPainter &, int glyph, int cellx, int celly);
|
||||
|
||||
private:
|
||||
QImage img;
|
||||
QPixmap pm, pm1, pm2;
|
||||
QSize size;
|
||||
int tiles_per_row;
|
||||
};
|
||||
|
||||
class BlackScrollView : public QScrollView
|
||||
{
|
||||
public:
|
||||
BlackScrollView()
|
||||
{
|
||||
viewport()->setBackgroundColor(black);
|
||||
}
|
||||
};
|
||||
|
||||
class NetHackQtMapWindow : public QWidget, public NetHackQtWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
private:
|
||||
NetHackQtClickBuffer &clicksink;
|
||||
unsigned short glyph[ROWNO][COLNO];
|
||||
unsigned short &
|
||||
Glyph(int x, int y)
|
||||
{
|
||||
return glyph[y][x];
|
||||
}
|
||||
QPoint cursor;
|
||||
BlackScrollView viewport;
|
||||
QPixmap pet_annotation;
|
||||
Clusterizer change;
|
||||
QFont *rogue_font;
|
||||
QString messages;
|
||||
QRect messages_rect;
|
||||
|
||||
void Changed(int x, int y);
|
||||
|
||||
signals:
|
||||
void resized();
|
||||
|
||||
private slots:
|
||||
void updateTiles();
|
||||
void moveMessages(int x, int y);
|
||||
#ifdef SAFERHANGUP
|
||||
void timeout();
|
||||
#endif
|
||||
|
||||
protected:
|
||||
virtual void paintEvent(QPaintEvent *);
|
||||
virtual void mousePressEvent(QMouseEvent *);
|
||||
|
||||
public:
|
||||
NetHackQtMapWindow(NetHackQtClickBuffer &click_sink);
|
||||
~NetHackQtMapWindow();
|
||||
|
||||
virtual QWidget *Widget();
|
||||
virtual bool Destroy();
|
||||
|
||||
virtual void Clear();
|
||||
virtual void Display(bool block);
|
||||
virtual void CursorTo(int x, int y);
|
||||
virtual void PutStr(int attr, const char *text);
|
||||
virtual void ClipAround(int x, int y);
|
||||
virtual void PrintGlyph(int x, int y, int glyph);
|
||||
|
||||
void Scroll(int dx, int dy);
|
||||
|
||||
// For messages
|
||||
void displayMessages(bool block);
|
||||
void putMessage(int attr, const char *text);
|
||||
void clearMessages();
|
||||
|
||||
void clickCursor();
|
||||
};
|
||||
|
||||
class NetHackQtScrollText;
|
||||
class NetHackQtMessageWindow : QObject, public NetHackQtWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
NetHackQtMessageWindow();
|
||||
~NetHackQtMessageWindow();
|
||||
|
||||
virtual QWidget *Widget();
|
||||
virtual void Clear();
|
||||
virtual void Display(bool block);
|
||||
virtual void PutStr(int attr, const char *text);
|
||||
|
||||
void Scroll(int dx, int dy);
|
||||
|
||||
void setMap(NetHackQtMapWindow *);
|
||||
|
||||
private:
|
||||
NetHackQtScrollText *list;
|
||||
bool changed;
|
||||
NetHackQtMapWindow *map;
|
||||
|
||||
private slots:
|
||||
void updateFont();
|
||||
};
|
||||
|
||||
class NetHackQtLabelledIcon : public QWidget
|
||||
{
|
||||
public:
|
||||
NetHackQtLabelledIcon(QWidget *parent, const char *label);
|
||||
NetHackQtLabelledIcon(QWidget *parent, const char *label,
|
||||
const QPixmap &icon);
|
||||
|
||||
enum { NoNum = -99999 };
|
||||
void setLabel(const char *, bool lower = TRUE); // a string
|
||||
void setLabel(const char *, long, const char *tail = ""); // a number
|
||||
void setLabel(const char *, long show_value, long comparative_value,
|
||||
const char *tail = "");
|
||||
void setIcon(const QPixmap &);
|
||||
virtual void setFont(const QFont &);
|
||||
|
||||
void highlightWhenChanging();
|
||||
void lowIsGood();
|
||||
void dissipateHighlight();
|
||||
|
||||
virtual void show();
|
||||
|
||||
protected:
|
||||
void resizeEvent(QResizeEvent *);
|
||||
|
||||
private:
|
||||
void initHighlight();
|
||||
void setAlignments();
|
||||
void highlight(const QPalette &highlight);
|
||||
void unhighlight();
|
||||
|
||||
bool low_is_good;
|
||||
int prev_value;
|
||||
int turn_count; /* last time the value changed */
|
||||
QPalette hl_good;
|
||||
QPalette hl_bad;
|
||||
|
||||
QLabel *label;
|
||||
QLabel *icon;
|
||||
};
|
||||
|
||||
class NetHackQtStatusWindow : QWidget, public NetHackQtWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
NetHackQtStatusWindow();
|
||||
|
||||
virtual QWidget *Widget();
|
||||
|
||||
virtual void Clear();
|
||||
virtual void Display(bool block);
|
||||
virtual void CursorTo(int x, int y);
|
||||
virtual void PutStr(int attr, const char *text);
|
||||
|
||||
void fadeHighlighting();
|
||||
|
||||
protected:
|
||||
void resizeEvent(QResizeEvent *);
|
||||
|
||||
private slots:
|
||||
void doUpdate();
|
||||
|
||||
private:
|
||||
enum { hilight_time = 1 };
|
||||
|
||||
QPixmap p_str;
|
||||
QPixmap p_dex;
|
||||
QPixmap p_con;
|
||||
QPixmap p_int;
|
||||
QPixmap p_wis;
|
||||
QPixmap p_cha;
|
||||
|
||||
QPixmap p_chaotic;
|
||||
QPixmap p_neutral;
|
||||
QPixmap p_lawful;
|
||||
|
||||
QPixmap p_satiated;
|
||||
QPixmap p_hungry;
|
||||
|
||||
QPixmap p_confused;
|
||||
QPixmap p_sick_fp;
|
||||
QPixmap p_sick_il;
|
||||
QPixmap p_blind;
|
||||
QPixmap p_stunned;
|
||||
QPixmap p_hallu;
|
||||
|
||||
QPixmap p_encumber[5];
|
||||
|
||||
NetHackQtLabelledIcon name;
|
||||
NetHackQtLabelledIcon dlevel;
|
||||
|
||||
NetHackQtLabelledIcon str;
|
||||
NetHackQtLabelledIcon dex;
|
||||
NetHackQtLabelledIcon con;
|
||||
NetHackQtLabelledIcon intel;
|
||||
NetHackQtLabelledIcon wis;
|
||||
NetHackQtLabelledIcon cha;
|
||||
|
||||
NetHackQtLabelledIcon gold;
|
||||
NetHackQtLabelledIcon hp;
|
||||
NetHackQtLabelledIcon power;
|
||||
NetHackQtLabelledIcon ac;
|
||||
NetHackQtLabelledIcon level;
|
||||
NetHackQtLabelledIcon exp;
|
||||
NetHackQtLabelledIcon align;
|
||||
|
||||
NetHackQtLabelledIcon time;
|
||||
NetHackQtLabelledIcon score;
|
||||
|
||||
NetHackQtLabelledIcon hunger;
|
||||
NetHackQtLabelledIcon confused;
|
||||
NetHackQtLabelledIcon sick_fp;
|
||||
NetHackQtLabelledIcon sick_il;
|
||||
NetHackQtLabelledIcon blind;
|
||||
NetHackQtLabelledIcon stunned;
|
||||
NetHackQtLabelledIcon hallu;
|
||||
NetHackQtLabelledIcon encumber;
|
||||
|
||||
QFrame hline1;
|
||||
QFrame hline2;
|
||||
QFrame hline3;
|
||||
|
||||
int cursy;
|
||||
|
||||
bool first_set;
|
||||
|
||||
void nullOut();
|
||||
void updateStats();
|
||||
void checkTurnEvents();
|
||||
};
|
||||
|
||||
class NetHackQtMenuDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
NetHackQtMenuDialog();
|
||||
|
||||
void Accept();
|
||||
void Reject();
|
||||
void SetResult(int);
|
||||
|
||||
virtual void done(int);
|
||||
|
||||
protected:
|
||||
void resizeEvent(QResizeEvent *);
|
||||
|
||||
signals:
|
||||
void Resized();
|
||||
};
|
||||
|
||||
class NetHackQtMenuWindow : public QTableView, public NetHackQtWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
NetHackQtMenuWindow(NetHackQtKeyBuffer &);
|
||||
~NetHackQtMenuWindow();
|
||||
|
||||
virtual QWidget *Widget();
|
||||
|
||||
virtual void StartMenu();
|
||||
virtual void AddMenu(int glyph, const ANY_P *identifier, char ch,
|
||||
char gch, int attr, const char *str, unsigned itemflags);
|
||||
virtual void EndMenu(const char *prompt);
|
||||
virtual int SelectMenu(int how, MENU_ITEM_P **menu_list);
|
||||
|
||||
public slots:
|
||||
void All();
|
||||
void ChooseNone();
|
||||
void Invert();
|
||||
void Search();
|
||||
|
||||
void Layout();
|
||||
void ToggleSelect(int);
|
||||
|
||||
protected:
|
||||
virtual void keyPressEvent(QKeyEvent *);
|
||||
// virtual void mouseDoubleClickEvent(QMouseEvent*);
|
||||
virtual void mousePressEvent(QMouseEvent *);
|
||||
virtual void mouseReleaseEvent(QMouseEvent *);
|
||||
virtual void mouseMoveEvent(QMouseEvent *);
|
||||
virtual void focusOutEvent(QFocusEvent *);
|
||||
virtual void focusInEvent(QFocusEvent *);
|
||||
|
||||
virtual void paintCell(QPainter *, int, int);
|
||||
virtual int cellWidth(int col);
|
||||
|
||||
private:
|
||||
struct MenuItem {
|
||||
MenuItem();
|
||||
~MenuItem();
|
||||
|
||||
int glyph;
|
||||
ANY_P identifier;
|
||||
int attr;
|
||||
const char *str;
|
||||
int count;
|
||||
char ch;
|
||||
bool selected;
|
||||
|
||||
bool
|
||||
Selectable() const
|
||||
{
|
||||
return identifier.a_void != 0;
|
||||
}
|
||||
};
|
||||
|
||||
QArray<MenuItem> item;
|
||||
|
||||
int itemcount;
|
||||
int str_width;
|
||||
bool str_fixed;
|
||||
int next_accel;
|
||||
|
||||
NetHackQtKeyBuffer &keysource;
|
||||
|
||||
NetHackQtMenuDialog *dialog;
|
||||
|
||||
QPushButton *ok;
|
||||
QPushButton *cancel;
|
||||
QPushButton *all;
|
||||
QPushButton *none;
|
||||
QPushButton *invert;
|
||||
QPushButton *search;
|
||||
QLabel prompt;
|
||||
|
||||
int how;
|
||||
|
||||
bool has_glyphs;
|
||||
|
||||
int pressed;
|
||||
bool was_sel;
|
||||
};
|
||||
|
||||
class NetHackQtTextListBox;
|
||||
|
||||
class NetHackQtRIP : public QWidget
|
||||
{
|
||||
private:
|
||||
static QPixmap *pixmap;
|
||||
char **line;
|
||||
int riplines;
|
||||
|
||||
public:
|
||||
NetHackQtRIP(QWidget *parent);
|
||||
|
||||
void setLines(char **l, int n);
|
||||
|
||||
protected:
|
||||
virtual void paintEvent(QPaintEvent *event);
|
||||
QSize sizeHint() const;
|
||||
};
|
||||
|
||||
class NetHackQtTextWindow : public QDialog, public NetHackQtWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
NetHackQtTextWindow(NetHackQtKeyBuffer &);
|
||||
~NetHackQtTextWindow();
|
||||
|
||||
virtual QWidget *Widget();
|
||||
|
||||
virtual void Clear();
|
||||
virtual bool Destroy();
|
||||
virtual void Display(bool block);
|
||||
virtual void PutStr(int attr, const char *text);
|
||||
virtual void UseRIP(int how, time_t when);
|
||||
|
||||
public slots:
|
||||
void Search();
|
||||
|
||||
protected:
|
||||
virtual void done(int);
|
||||
virtual void keyPressEvent(QKeyEvent *);
|
||||
|
||||
private slots:
|
||||
void doUpdate();
|
||||
|
||||
private:
|
||||
NetHackQtKeyBuffer &keysource;
|
||||
|
||||
bool use_rip;
|
||||
bool str_fixed;
|
||||
|
||||
QPushButton ok;
|
||||
QPushButton search;
|
||||
NetHackQtTextListBox *lines;
|
||||
|
||||
NetHackQtRIP rip;
|
||||
};
|
||||
|
||||
class NetHackQtMenuOrTextWindow : public NetHackQtWindow
|
||||
{
|
||||
private:
|
||||
NetHackQtWindow *actual;
|
||||
NetHackQtKeyBuffer &keysource;
|
||||
|
||||
public:
|
||||
NetHackQtMenuOrTextWindow(NetHackQtKeyBuffer &);
|
||||
|
||||
virtual QWidget *Widget();
|
||||
|
||||
// Text
|
||||
virtual void Clear();
|
||||
virtual bool Destroy();
|
||||
virtual void Display(bool block);
|
||||
virtual void PutStr(int attr, const char *text);
|
||||
|
||||
// Menu
|
||||
virtual void StartMenu();
|
||||
virtual void AddMenu(int glyph, const ANY_P *identifier, char ch,
|
||||
char gch, int attr, const char *str, unsigned itemflags);
|
||||
virtual void EndMenu(const char *prompt);
|
||||
virtual int SelectMenu(int how, MENU_ITEM_P **menu_list);
|
||||
};
|
||||
|
||||
class NetHackQtDelay : QObject
|
||||
{
|
||||
private:
|
||||
int msec;
|
||||
|
||||
public:
|
||||
NetHackQtDelay(int ms);
|
||||
void wait();
|
||||
virtual void timerEvent(QTimerEvent *timer);
|
||||
};
|
||||
|
||||
class NetHackQtInvUsageWindow : public QWidget
|
||||
{
|
||||
public:
|
||||
NetHackQtInvUsageWindow(QWidget *parent);
|
||||
virtual void paintEvent(QPaintEvent *);
|
||||
|
||||
private:
|
||||
void drawWorn(QPainter &painter, obj *, int x, int y, bool canbe = TRUE);
|
||||
};
|
||||
|
||||
// This class is the main widget for NetHack
|
||||
//
|
||||
// It is a collection of Message, Map, and Status windows. In the current
|
||||
// version of nethack there is only one of each, and this class makes this
|
||||
// assumption, not showing itself until all are inserted.
|
||||
//
|
||||
// This class simply knows how to layout such children sensibly.
|
||||
//
|
||||
// Since it is only responsible for layout, the class does not
|
||||
// note the actual class of the windows.
|
||||
//
|
||||
#ifndef KDE
|
||||
#include "qt3_kde0.h"
|
||||
#endif
|
||||
|
||||
class NetHackQtMainWindow : public KTopLevelWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
NetHackQtMainWindow(NetHackQtKeyBuffer &);
|
||||
|
||||
void AddMessageWindow(NetHackQtMessageWindow *window);
|
||||
void AddMapWindow(NetHackQtMapWindow *window);
|
||||
void AddStatusWindow(NetHackQtStatusWindow *window);
|
||||
void RemoveWindow(NetHackQtWindow *window);
|
||||
void updateInventory();
|
||||
|
||||
void fadeHighlighting();
|
||||
|
||||
public slots:
|
||||
void doMenuItem(int);
|
||||
void doKeys(const QString &);
|
||||
|
||||
protected:
|
||||
virtual void resizeEvent(QResizeEvent *);
|
||||
virtual void keyPressEvent(QKeyEvent *);
|
||||
virtual void keyReleaseEvent(QKeyEvent *event);
|
||||
virtual void closeEvent(QCloseEvent *);
|
||||
|
||||
private slots:
|
||||
void layout();
|
||||
void raiseMap();
|
||||
void zoomMap();
|
||||
void raiseMessages();
|
||||
void raiseStatus();
|
||||
|
||||
private:
|
||||
void ShowIfReady();
|
||||
|
||||
#ifdef KDE
|
||||
KMenuBar *menubar;
|
||||
#else
|
||||
QMenuBar *menubar;
|
||||
#endif
|
||||
NetHackQtMessageWindow *message;
|
||||
NetHackQtMapWindow *map;
|
||||
NetHackQtStatusWindow *status;
|
||||
NetHackQtInvUsageWindow *invusage;
|
||||
|
||||
NetHackQtKeyBuffer &keysink;
|
||||
QWidgetStack *stack;
|
||||
int dirkey;
|
||||
|
||||
const char **macro;
|
||||
};
|
||||
|
||||
class NetHackQtYnDialog : QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
private:
|
||||
const char *question;
|
||||
const char *choices;
|
||||
char def;
|
||||
NetHackQtKeyBuffer &keysource;
|
||||
|
||||
protected:
|
||||
virtual void keyPressEvent(QKeyEvent *);
|
||||
virtual void done(int);
|
||||
|
||||
private slots:
|
||||
void doneItem(int);
|
||||
|
||||
public:
|
||||
NetHackQtYnDialog(NetHackQtKeyBuffer &keysource, const char *,
|
||||
const char *, char);
|
||||
|
||||
char Exec();
|
||||
};
|
||||
|
||||
#ifdef KDE
|
||||
#define NetHackQtBindBase KApplication
|
||||
#elif defined(QWS)
|
||||
#define NetHackQtBindBase QPEApplication
|
||||
#else
|
||||
#define NetHackQtBindBase QApplication
|
||||
#endif
|
||||
|
||||
class NetHackQtBind : NetHackQtBindBase
|
||||
{
|
||||
private:
|
||||
// Single-instance preservation...
|
||||
NetHackQtBind(int &argc, char **argv);
|
||||
|
||||
static NetHackQtBind *instance;
|
||||
|
||||
static NetHackQtKeyBuffer keybuffer;
|
||||
static NetHackQtClickBuffer clickbuffer;
|
||||
|
||||
static QWidget *splash;
|
||||
static NetHackQtMainWindow *main;
|
||||
|
||||
public:
|
||||
static void qt_init_nhwindows(int *argc, char **argv);
|
||||
static void qt_player_selection();
|
||||
static void qt_askname();
|
||||
static void qt_get_nh_event();
|
||||
static void qt_exit_nhwindows(const char *);
|
||||
static void qt_suspend_nhwindows(const char *);
|
||||
static void qt_resume_nhwindows();
|
||||
static winid qt_create_nhwindow(int type);
|
||||
static void qt_clear_nhwindow(winid wid);
|
||||
static void qt_display_nhwindow(winid wid, BOOLEAN_P block);
|
||||
static void qt_destroy_nhwindow(winid wid);
|
||||
static void qt_curs(winid wid, int x, int y);
|
||||
static void qt_putstr(winid wid, int attr, const char *text);
|
||||
static void qt_display_file(const char *filename, BOOLEAN_P must_exist);
|
||||
static void qt_start_menu(winid wid, unsigned long mbehavior);
|
||||
static void qt_add_menu(winid wid, int glyph, const ANY_P *identifier,
|
||||
CHAR_P ch, CHAR_P gch, int attr, const char *str,
|
||||
unsigned itemflags);
|
||||
static void qt_end_menu(winid wid, const char *prompt);
|
||||
static int qt_select_menu(winid wid, int how, MENU_ITEM_P **menu_list);
|
||||
static void qt_update_inventory();
|
||||
static void qt_mark_synch();
|
||||
static void qt_wait_synch();
|
||||
|
||||
static void qt_cliparound(int x, int y);
|
||||
static void qt_cliparound_window(winid wid, int x, int y);
|
||||
static void qt_print_glyph(winid wid, XCHAR_P x, XCHAR_P y,
|
||||
int glyph, int bkglyph);
|
||||
static void qt_raw_print(const char *str);
|
||||
static void qt_raw_print_bold(const char *str);
|
||||
static int qt_nhgetch();
|
||||
static int qt_nh_poskey(int *x, int *y, int *mod);
|
||||
static void qt_nhbell();
|
||||
static int qt_doprev_message();
|
||||
static char qt_yn_function(const char *question, const char *choices,
|
||||
CHAR_P def);
|
||||
static void qt_getlin(const char *prompt, char *line);
|
||||
static int qt_get_ext_cmd();
|
||||
static void qt_number_pad(int);
|
||||
static void qt_delay_output();
|
||||
static void qt_start_screen();
|
||||
static void qt_end_screen();
|
||||
|
||||
static void qt_outrip(winid wid, int how, time_t when);
|
||||
static int qt_kbhit();
|
||||
|
||||
private:
|
||||
virtual bool notify(QObject *receiver, QEvent *event);
|
||||
};
|
||||
|
||||
#endif
|
||||
1422
outdated/win/Qt3/qt3_xpms.h
Normal file
1422
outdated/win/Qt3/qt3_xpms.h
Normal file
File diff suppressed because it is too large
Load Diff
2276
outdated/win/Qt3/qt3tableview.cpp
Normal file
2276
outdated/win/Qt3/qt3tableview.cpp
Normal file
File diff suppressed because it is too large
Load Diff
293
outdated/win/Qt3/qt3tableview.h
Normal file
293
outdated/win/Qt3/qt3tableview.h
Normal file
@@ -0,0 +1,293 @@
|
||||
/**********************************************************************
|
||||
** $NHDT-Date: 1524683840 2018/04/25 19:17:20 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.5 $
|
||||
** $Id: qttableview.h,v 1.2 2002/03/09 03:13:13 jwalz Exp $
|
||||
**
|
||||
** Definition of QtTableView class
|
||||
**
|
||||
** Created : 941115
|
||||
**
|
||||
** Copyright (C) 1992-2000 Trolltech AS. All rights reserved.
|
||||
**
|
||||
** This file contains a class moved out of the Qt GUI Toolkit API. It
|
||||
** may be used, distributed and modified without limitation.
|
||||
**
|
||||
**********************************************************************/
|
||||
|
||||
#ifndef QTTABLEVIEW_H
|
||||
#define QTTABLEVIEW_H
|
||||
|
||||
#ifndef QT_H
|
||||
#include <qframe.h>
|
||||
#endif // QT_H
|
||||
|
||||
#ifndef QT_NO_QTTABLEVIEW
|
||||
|
||||
class QScrollBar;
|
||||
class QCornerSquare;
|
||||
|
||||
class QtTableView : public QFrame
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
virtual void setBackgroundColor(const QColor &);
|
||||
virtual void setPalette(const QPalette &);
|
||||
void show();
|
||||
|
||||
void repaint(bool erase = TRUE);
|
||||
void repaint(int x, int y, int w, int h, bool erase = TRUE);
|
||||
void repaint(const QRect &, bool erase = TRUE);
|
||||
|
||||
protected:
|
||||
QtTableView(QWidget *parent = 0, const char *name = 0, WFlags f = 0);
|
||||
~QtTableView();
|
||||
|
||||
int numRows() const;
|
||||
virtual void setNumRows(int);
|
||||
int numCols() const;
|
||||
virtual void setNumCols(int);
|
||||
|
||||
int topCell() const;
|
||||
virtual void setTopCell(int row);
|
||||
int leftCell() const;
|
||||
virtual void setLeftCell(int col);
|
||||
virtual void setTopLeftCell(int row, int col);
|
||||
|
||||
int xOffset() const;
|
||||
virtual void setXOffset(int);
|
||||
int yOffset() const;
|
||||
virtual void setYOffset(int);
|
||||
virtual void setOffset(int x, int y, bool updateScrBars = TRUE);
|
||||
|
||||
virtual int cellWidth(int col);
|
||||
virtual int cellHeight(int row);
|
||||
int cellWidth() const;
|
||||
int cellHeight() const;
|
||||
virtual void setCellWidth(int);
|
||||
virtual void setCellHeight(int);
|
||||
|
||||
virtual int totalWidth();
|
||||
virtual int totalHeight();
|
||||
|
||||
uint tableFlags() const;
|
||||
bool testTableFlags(uint f) const;
|
||||
virtual void setTableFlags(uint f);
|
||||
void clearTableFlags(uint f = ~0);
|
||||
|
||||
bool autoUpdate() const;
|
||||
virtual void setAutoUpdate(bool);
|
||||
|
||||
void updateCell(int row, int column, bool erase = TRUE);
|
||||
|
||||
QRect cellUpdateRect() const;
|
||||
QRect viewRect() const;
|
||||
|
||||
int lastRowVisible() const;
|
||||
int lastColVisible() const;
|
||||
|
||||
bool rowIsVisible(int row) const;
|
||||
bool colIsVisible(int col) const;
|
||||
|
||||
QScrollBar *verticalScrollBar() const;
|
||||
QScrollBar *horizontalScrollBar() const;
|
||||
|
||||
private slots:
|
||||
void horSbValue(int);
|
||||
void horSbSliding(int);
|
||||
void horSbSlidingDone();
|
||||
void verSbValue(int);
|
||||
void verSbSliding(int);
|
||||
void verSbSlidingDone();
|
||||
|
||||
protected:
|
||||
virtual void paintCell(QPainter *, int row, int col) = 0;
|
||||
virtual void setupPainter(QPainter *);
|
||||
|
||||
void paintEvent(QPaintEvent *);
|
||||
void resizeEvent(QResizeEvent *);
|
||||
|
||||
int findRow(int yPos) const;
|
||||
int findCol(int xPos) const;
|
||||
|
||||
bool rowYPos(int row, int *yPos) const;
|
||||
bool colXPos(int col, int *xPos) const;
|
||||
|
||||
int maxXOffset();
|
||||
int maxYOffset();
|
||||
int maxColOffset();
|
||||
int maxRowOffset();
|
||||
|
||||
int minViewX() const;
|
||||
int minViewY() const;
|
||||
int maxViewX() const;
|
||||
int maxViewY() const;
|
||||
int viewWidth() const;
|
||||
int viewHeight() const;
|
||||
|
||||
void scroll(int xPixels, int yPixels);
|
||||
void updateScrollBars();
|
||||
void updateTableSize();
|
||||
|
||||
private:
|
||||
void coverCornerSquare(bool);
|
||||
void snapToGrid(bool horizontal, bool vertical);
|
||||
virtual void setHorScrollBar(bool on, bool update = TRUE);
|
||||
virtual void setVerScrollBar(bool on, bool update = TRUE);
|
||||
void updateView();
|
||||
int findRawRow(int yPos, int *cellMaxY, int *cellMinY = 0,
|
||||
bool goOutsideView = FALSE) const;
|
||||
int findRawCol(int xPos, int *cellMaxX, int *cellMinX = 0,
|
||||
bool goOutsideView = FALSE) const;
|
||||
int maxColsVisible() const;
|
||||
|
||||
void updateScrollBars(uint);
|
||||
void updateFrameSize();
|
||||
|
||||
void doAutoScrollBars();
|
||||
void showOrHideScrollBars();
|
||||
|
||||
int nRows;
|
||||
int nCols;
|
||||
int xOffs, yOffs;
|
||||
int xCellOffs, yCellOffs;
|
||||
short xCellDelta, yCellDelta;
|
||||
short cellH, cellW;
|
||||
|
||||
uint eraseInPaint : 1;
|
||||
uint verSliding : 1;
|
||||
uint verSnappingOff : 1;
|
||||
uint horSliding : 1;
|
||||
uint horSnappingOff : 1;
|
||||
uint coveringCornerSquare : 1;
|
||||
uint sbDirty : 8;
|
||||
uint inSbUpdate : 1;
|
||||
|
||||
uint tFlags;
|
||||
QRect cellUpdateR;
|
||||
|
||||
QScrollBar *vScrollBar;
|
||||
QScrollBar *hScrollBar;
|
||||
QCornerSquare *cornerSquare;
|
||||
|
||||
private: // Disabled copy constructor and operator=
|
||||
#if defined(Q_DISABLE_COPY)
|
||||
QtTableView(const QtTableView &);
|
||||
QtTableView &operator=(const QtTableView &);
|
||||
#endif
|
||||
};
|
||||
|
||||
const uint Tbl_vScrollBar = 0x00000001;
|
||||
const uint Tbl_hScrollBar = 0x00000002;
|
||||
const uint Tbl_autoVScrollBar = 0x00000004;
|
||||
const uint Tbl_autoHScrollBar = 0x00000008;
|
||||
const uint Tbl_autoScrollBars = 0x0000000C;
|
||||
|
||||
const uint Tbl_clipCellPainting = 0x00000100;
|
||||
const uint Tbl_cutCellsV = 0x00000200;
|
||||
const uint Tbl_cutCellsH = 0x00000400;
|
||||
const uint Tbl_cutCells = 0x00000600;
|
||||
|
||||
const uint Tbl_scrollLastHCell = 0x00000800;
|
||||
const uint Tbl_scrollLastVCell = 0x00001000;
|
||||
const uint Tbl_scrollLastCell = 0x00001800;
|
||||
|
||||
const uint Tbl_smoothHScrolling = 0x00002000;
|
||||
const uint Tbl_smoothVScrolling = 0x00004000;
|
||||
const uint Tbl_smoothScrolling = 0x00006000;
|
||||
|
||||
const uint Tbl_snapToHGrid = 0x00008000;
|
||||
const uint Tbl_snapToVGrid = 0x00010000;
|
||||
const uint Tbl_snapToGrid = 0x00018000;
|
||||
|
||||
inline int
|
||||
QtTableView::numRows() const
|
||||
{
|
||||
return nRows;
|
||||
}
|
||||
|
||||
inline int
|
||||
QtTableView::numCols() const
|
||||
{
|
||||
return nCols;
|
||||
}
|
||||
|
||||
inline int
|
||||
QtTableView::topCell() const
|
||||
{
|
||||
return yCellOffs;
|
||||
}
|
||||
|
||||
inline int
|
||||
QtTableView::leftCell() const
|
||||
{
|
||||
return xCellOffs;
|
||||
}
|
||||
|
||||
inline int
|
||||
QtTableView::xOffset() const
|
||||
{
|
||||
return xOffs;
|
||||
}
|
||||
|
||||
inline int
|
||||
QtTableView::yOffset() const
|
||||
{
|
||||
return yOffs;
|
||||
}
|
||||
|
||||
inline int
|
||||
QtTableView::cellHeight() const
|
||||
{
|
||||
return cellH;
|
||||
}
|
||||
|
||||
inline int
|
||||
QtTableView::cellWidth() const
|
||||
{
|
||||
return cellW;
|
||||
}
|
||||
|
||||
inline uint
|
||||
QtTableView::tableFlags() const
|
||||
{
|
||||
return tFlags;
|
||||
}
|
||||
|
||||
inline bool
|
||||
QtTableView::testTableFlags(uint f) const
|
||||
{
|
||||
return (tFlags & f) != 0;
|
||||
}
|
||||
|
||||
inline QRect
|
||||
QtTableView::cellUpdateRect() const
|
||||
{
|
||||
return cellUpdateR;
|
||||
}
|
||||
|
||||
inline bool
|
||||
QtTableView::autoUpdate() const
|
||||
{
|
||||
return isUpdatesEnabled();
|
||||
}
|
||||
|
||||
inline void
|
||||
QtTableView::repaint(bool erase)
|
||||
{
|
||||
repaint(0, 0, width(), height(), erase);
|
||||
}
|
||||
|
||||
inline void
|
||||
QtTableView::repaint(const QRect &r, bool erase)
|
||||
{
|
||||
repaint(r.x(), r.y(), r.width(), r.height(), erase);
|
||||
}
|
||||
|
||||
inline void
|
||||
QtTableView::updateScrollBars()
|
||||
{
|
||||
updateScrollBars(0);
|
||||
}
|
||||
|
||||
#endif // QT_NO_QTTABLEVIEW
|
||||
|
||||
#endif // QTTABLEVIEW_H
|
||||
413
outdated/win/Qt3/tileedit.cpp
Normal file
413
outdated/win/Qt3/tileedit.cpp
Normal file
@@ -0,0 +1,413 @@
|
||||
/* NetHack 3.6 tileedit.cpp $NHDT-Date: 1524684508 2018/04/25 19:28:28 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.10 $ */
|
||||
/* Copyright (c) Warwick Allison, 1999. */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
/*
|
||||
Build this little utility program if you want to use it to edit the tile
|
||||
files. Move tileedit.cpp and tileedit.h to ../../util, add the
|
||||
3 lines below to the Makefile there and "make tileedit".
|
||||
|
||||
tileedit: tileedit.cpp $(TEXT_IO)
|
||||
moc -o tileedit.moc tileedit.h
|
||||
$(CC) -o tileedit -I../include -I$(QTDIR)/include -L$(QTDIR)/lib tileedit.cpp $(TEXT_IO) -lqt
|
||||
*/
|
||||
|
||||
|
||||
#include "tileedit.h"
|
||||
#include <qapplication.h>
|
||||
#include <qmainwindow.h>
|
||||
#include <qkeycode.h>
|
||||
#include <qpopupmenu.h>
|
||||
#include <qmenubar.h>
|
||||
#include <qpainter.h>
|
||||
#include <qstatusbar.h>
|
||||
#include <qhbox.h>
|
||||
#include <qlabel.h>
|
||||
|
||||
extern "C" {
|
||||
#include "config.h"
|
||||
#include "tile.h"
|
||||
extern const char *FDECL(tilename, (int, int));
|
||||
}
|
||||
|
||||
#define TILES_ACROSS 20
|
||||
|
||||
TilePickerTab::TilePickerTab(const char* basename, int i, QWidget* parent) :
|
||||
QWidget(parent)
|
||||
{
|
||||
id = i;
|
||||
filename = basename;
|
||||
filename += ".txt";
|
||||
num = 0;
|
||||
int index = 0;
|
||||
for (int real=0; real<2; real++) {
|
||||
if ( real ) {
|
||||
image.create( TILES_ACROSS*TILE_X,
|
||||
((num+TILES_ACROSS-1)/TILES_ACROSS)*TILE_Y, 32 );
|
||||
}
|
||||
if ( !fopen_text_file(filename.latin1(), RDTMODE) ) {
|
||||
// XXX handle better
|
||||
exit(1);
|
||||
}
|
||||
pixel p[TILE_Y][TILE_X];
|
||||
while ( read_text_tile(p) ) {
|
||||
if ( real ) {
|
||||
int ox = (index%TILES_ACROSS)*TILE_X;
|
||||
int oy = (index/TILES_ACROSS)*TILE_Y;
|
||||
for ( int y=0; y<TILE_Y; y++ ) {
|
||||
QRgb* rgb = ((QRgb*)image.scanLine(oy+y)) + ox;
|
||||
for ( int x=0; x<TILE_X; x++ ) {
|
||||
*rgb++ = qRgb(p[y][x].r, p[y][x].g, p[y][x].b);
|
||||
}
|
||||
}
|
||||
index++;
|
||||
} else {
|
||||
// Just count...
|
||||
num++;
|
||||
}
|
||||
}
|
||||
fclose_text_file();
|
||||
}
|
||||
image = image.convertDepth( 8, AvoidDither );
|
||||
pixmap.convertFromImage( image );
|
||||
}
|
||||
|
||||
bool TilePickerTab::save()
|
||||
{
|
||||
if ( !fopen_text_file(filename.latin1(), WRTMODE) ) {
|
||||
// XXX handle better
|
||||
exit(1);
|
||||
}
|
||||
pixel p[TILE_Y][TILE_X];
|
||||
for ( int index=0; index < num; index++ ) {
|
||||
int ox = (index%TILES_ACROSS)*TILE_X;
|
||||
int oy = (index/TILES_ACROSS)*TILE_Y;
|
||||
for ( int y=0; y<TILE_Y; y++ ) {
|
||||
uchar* c = image.scanLine(oy+y) + ox;
|
||||
for ( int x=0; x<TILE_X; x++ ) {
|
||||
QRgb rgb = image.color(*c++);
|
||||
p[y][x].r = qRed(rgb);
|
||||
p[y][x].g = qGreen(rgb);
|
||||
p[y][x].b = qBlue(rgb);
|
||||
}
|
||||
}
|
||||
write_text_tile(p);
|
||||
}
|
||||
fclose_text_file();
|
||||
}
|
||||
|
||||
void TilePickerTab::mousePressEvent(QMouseEvent* e)
|
||||
{
|
||||
int ox = e->x()-e->x()%TILE_X;
|
||||
int oy = e->y()-e->y()%TILE_Y;
|
||||
QImage subimage = image.copy(ox,oy,TILE_X,TILE_Y);
|
||||
if ( e->button() == RightButton ) {
|
||||
setCurrent(subimage);
|
||||
} else {
|
||||
last_pick = ox/TILE_X + oy/TILE_Y*TILES_ACROSS;
|
||||
}
|
||||
emit pick(subimage);
|
||||
emit pickName(tilename(id, last_pick));
|
||||
}
|
||||
|
||||
void TilePickerTab::setCurrent(const QImage& i)
|
||||
{
|
||||
int ox = last_pick%TILES_ACROSS * TILE_X;
|
||||
int oy = last_pick/TILES_ACROSS * TILE_Y;
|
||||
bitBlt( &image, ox, oy, &i );
|
||||
bitBlt( &pixmap, ox, oy, &i );
|
||||
repaint( ox, oy, TILE_X, TILE_Y, FALSE );
|
||||
}
|
||||
|
||||
QSize TilePickerTab::sizeHint() const
|
||||
{
|
||||
return pixmap.size();
|
||||
}
|
||||
|
||||
void TilePickerTab::paintEvent( QPaintEvent* )
|
||||
{
|
||||
QPainter p(this);
|
||||
p.drawPixmap(0,0,pixmap);
|
||||
}
|
||||
|
||||
static struct {
|
||||
const char* name;
|
||||
TilePickerTab* tab;
|
||||
} tileset[] = {
|
||||
{ "monsters", 0 },
|
||||
{ "objects", 0 },
|
||||
{ "other", 0 },
|
||||
{ 0 }
|
||||
};
|
||||
|
||||
TilePicker::TilePicker(QWidget* parent) :
|
||||
QTabWidget(parent)
|
||||
{
|
||||
for (int i=0; tileset[i].name; i++) {
|
||||
QString tabname = tileset[i].name;
|
||||
tabname[0] = tabname[0].upper();
|
||||
tileset[i].tab = new TilePickerTab(tileset[i].name,i+1,this);
|
||||
addTab( tileset[i].tab, tabname );
|
||||
connect( tileset[i].tab, SIGNAL(pick(const QImage&)),
|
||||
this, SIGNAL(pick(const QImage&)) );
|
||||
connect( tileset[i].tab, SIGNAL(pickName(const QString&)),
|
||||
this, SIGNAL(pickName(const QString&)) );
|
||||
}
|
||||
}
|
||||
|
||||
void TilePicker::setCurrent(const QImage& i)
|
||||
{
|
||||
((TilePickerTab*)currentPage())->setCurrent(i);
|
||||
}
|
||||
|
||||
void TilePicker::save()
|
||||
{
|
||||
for (int i=0; tileset[i].tab; i++) {
|
||||
tileset[i].tab->save();
|
||||
}
|
||||
}
|
||||
|
||||
TrivialTileEditor::TrivialTileEditor( QWidget* parent ) :
|
||||
QWidget(parent)
|
||||
{
|
||||
}
|
||||
|
||||
const QImage& TrivialTileEditor::image() const
|
||||
{
|
||||
return img;
|
||||
}
|
||||
|
||||
void TrivialTileEditor::setColor( QRgb rgb )
|
||||
{
|
||||
pen = rgb;
|
||||
for (penpixel = 0;
|
||||
penpixel<img.numColors()-1 && (img.color(penpixel)&0xffffff)!=(pen.rgb()&0xffffff);
|
||||
penpixel++)
|
||||
continue;
|
||||
}
|
||||
|
||||
void TrivialTileEditor::setImage( const QImage& i )
|
||||
{
|
||||
img = i;
|
||||
setColor(pen.rgb()); // update penpixel
|
||||
repaint(FALSE);
|
||||
}
|
||||
|
||||
void TrivialTileEditor::paintEvent( QPaintEvent* e )
|
||||
{
|
||||
QRect r = e->rect();
|
||||
QPoint tl = imagePoint(r.topLeft());
|
||||
QPoint br = imagePoint(r.bottomRight());
|
||||
r = QRect(tl,br).intersect(img.rect());
|
||||
QPainter painter(this);
|
||||
for (int y=r.top(); y<=r.bottom(); y++) {
|
||||
for (int x=r.left(); x<=r.right(); x++) {
|
||||
paintPoint(painter,QPoint(x,y));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TrivialTileEditor::paintPoint(QPainter& painter, QPoint p)
|
||||
{
|
||||
QPoint p1 = screenPoint(p);
|
||||
QPoint p2 = screenPoint(p+QPoint(1,1));
|
||||
QColor c = img.color(img.scanLine(p.y())[p.x()]);
|
||||
painter.fillRect(QRect(p1,p2-QPoint(1,1)), c);
|
||||
}
|
||||
|
||||
void TrivialTileEditor::mousePressEvent(QMouseEvent* e)
|
||||
{
|
||||
QPoint p = imagePoint(e->pos());
|
||||
if ( !img.rect().contains(p) )
|
||||
return;
|
||||
uchar& pixel = img.scanLine(p.y())[p.x()];
|
||||
if ( e->button() == LeftButton ) {
|
||||
pixel = penpixel;
|
||||
QPainter painter(this);
|
||||
paintPoint(painter,p);
|
||||
} else if ( e->button() == RightButton ) {
|
||||
emit pick( img.color(pixel) );
|
||||
} else if ( e->button() == MidButton ) {
|
||||
QPainter painter(this);
|
||||
if ( pixel != penpixel )
|
||||
fill(painter,p,pixel);
|
||||
}
|
||||
}
|
||||
|
||||
void TrivialTileEditor::fill(QPainter& painter, QPoint p, uchar from)
|
||||
{
|
||||
if ( img.rect().contains(p) ) {
|
||||
uchar& pixel = img.scanLine(p.y())[p.x()];
|
||||
if ( pixel == from ) {
|
||||
pixel = penpixel;
|
||||
paintPoint(painter,p);
|
||||
fill(painter, p+QPoint(-1,0), from);
|
||||
fill(painter, p+QPoint(+1,0), from);
|
||||
fill(painter, p+QPoint(0,-1), from);
|
||||
fill(painter, p+QPoint(0,+1), from);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TrivialTileEditor::mouseReleaseEvent(QMouseEvent* e)
|
||||
{
|
||||
emit edited(image());
|
||||
}
|
||||
|
||||
void TrivialTileEditor::mouseMoveEvent(QMouseEvent* e)
|
||||
{
|
||||
QPoint p = imagePoint(e->pos());
|
||||
if ( !img.rect().contains(p) )
|
||||
return;
|
||||
uchar& pixel = img.scanLine(p.y())[p.x()];
|
||||
pixel = penpixel;
|
||||
QPainter painter(this);
|
||||
paintPoint(painter,p);
|
||||
}
|
||||
|
||||
QPoint TrivialTileEditor::imagePoint(QPoint p) const
|
||||
{
|
||||
return QPoint(p.x()*TILE_X/width(), p.y()*TILE_Y/height());
|
||||
}
|
||||
|
||||
QPoint TrivialTileEditor::screenPoint(QPoint p) const
|
||||
{
|
||||
return QPoint(p.x()*width()/TILE_X, p.y()*height()/TILE_Y);
|
||||
}
|
||||
|
||||
QSizePolicy TrivialTileEditor::sizePolicy() const
|
||||
{
|
||||
return QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding, TRUE );
|
||||
}
|
||||
|
||||
QSize TrivialTileEditor::sizeHint() const
|
||||
{
|
||||
return sizeForWidth(-1);
|
||||
}
|
||||
|
||||
QSize TrivialTileEditor::sizeForWidth(int w) const
|
||||
{
|
||||
if ( w < 0 )
|
||||
return QSize(TILE_X*32,TILE_Y*32);
|
||||
else
|
||||
return QSize(w,w*TILE_Y/TILE_X);
|
||||
}
|
||||
|
||||
|
||||
TilePalette::TilePalette( QWidget* parent ) :
|
||||
QWidget(parent)
|
||||
{
|
||||
num = 0;
|
||||
rgb = 0;
|
||||
}
|
||||
|
||||
TilePalette::~TilePalette()
|
||||
{
|
||||
delete rgb;
|
||||
}
|
||||
|
||||
void TilePalette::setFromImage( const QImage& i )
|
||||
{
|
||||
num = i.numColors();
|
||||
rgb = new QRgb[num];
|
||||
memcpy(rgb, i.colorTable(), num*sizeof(QRgb));
|
||||
repaint(FALSE);
|
||||
}
|
||||
|
||||
void TilePalette::setColor(QRgb c)
|
||||
{
|
||||
for (int i=0; i<num; i++)
|
||||
if ( c == rgb[i] ) {
|
||||
emit pick(c);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
QSizePolicy TilePalette::sizePolicy() const
|
||||
{
|
||||
return QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum, FALSE );
|
||||
}
|
||||
|
||||
QSize TilePalette::sizeHint() const
|
||||
{
|
||||
return QSize(num*16,16);
|
||||
}
|
||||
|
||||
void TilePalette::paintEvent( QPaintEvent* )
|
||||
{
|
||||
QPainter p(this);
|
||||
for (int i=0; i<num; i++) {
|
||||
int x1 = width()*i/num;
|
||||
int x2 = width()*(i+1)/num;
|
||||
p.fillRect(x1,0,x2-x1,height(),QColor(rgb[i]));
|
||||
}
|
||||
}
|
||||
|
||||
void TilePalette::mousePressEvent(QMouseEvent* e)
|
||||
{
|
||||
int c = e->x()*num/width();
|
||||
emit pick(rgb[c]);
|
||||
}
|
||||
|
||||
TileEditor::TileEditor(QWidget* parent) :
|
||||
QVBox(parent),
|
||||
editor(this),
|
||||
palette(this)
|
||||
{
|
||||
connect( &palette, SIGNAL(pick(QRgb)),
|
||||
&editor, SLOT(setColor(QRgb)) );
|
||||
connect( &editor, SIGNAL(pick(QRgb)),
|
||||
&palette, SLOT(setColor(QRgb)) );
|
||||
connect( &editor, SIGNAL(edited(const QImage&)),
|
||||
this, SIGNAL(edited(const QImage&)) );
|
||||
}
|
||||
|
||||
void TileEditor::edit(const QImage& i)
|
||||
{
|
||||
editor.setImage(i);
|
||||
palette.setFromImage(i);
|
||||
}
|
||||
|
||||
const QImage& TileEditor::image() const
|
||||
{
|
||||
return editor.image();
|
||||
}
|
||||
|
||||
class Main : public QMainWindow {
|
||||
public:
|
||||
Main() :
|
||||
central(this),
|
||||
editor(¢ral),
|
||||
picker(¢ral)
|
||||
{
|
||||
QPopupMenu* file = new QPopupMenu(menuBar());
|
||||
file->insertItem("&Save", &picker, SLOT(save()), CTRL+Key_S);
|
||||
file->insertSeparator();
|
||||
file->insertItem("&Exit", qApp, SLOT(quit()), CTRL+Key_Q);
|
||||
menuBar()->insertItem("&File", file);
|
||||
|
||||
connect( &picker, SIGNAL(pick(const QImage&)),
|
||||
&editor, SLOT(edit(const QImage&)) );
|
||||
connect( &picker, SIGNAL(pickName(const QString&)),
|
||||
statusBar(), SLOT(message(const QString&)) );
|
||||
connect( &editor, SIGNAL(edited(const QImage&)),
|
||||
&picker, SLOT(setCurrent(const QImage&)) );
|
||||
|
||||
setCentralWidget(¢ral);
|
||||
}
|
||||
|
||||
private:
|
||||
QHBox central;
|
||||
TileEditor editor;
|
||||
TilePicker picker;
|
||||
};
|
||||
|
||||
main(int argc, char** argv)
|
||||
{
|
||||
QApplication app(argc,argv);
|
||||
Main m;
|
||||
app.setMainWidget(&m);
|
||||
m.show();
|
||||
return app.exec();
|
||||
}
|
||||
|
||||
#include "tileedit.moc"
|
||||
135
outdated/win/Qt3/tileedit.h
Normal file
135
outdated/win/Qt3/tileedit.h
Normal file
@@ -0,0 +1,135 @@
|
||||
/* NetHack 3.6 tileedit.h $NHDT-Date: 1432512809 2015/05/25 00:13:29 $ $NHDT-Branch: master $:$NHDT-Revision: 1.8 $ */
|
||||
/* Copyright (c) Warwick Allison, 1999. */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
#ifndef QNHTILEEDIT_H
|
||||
#define QNHTILEEDIT_H
|
||||
|
||||
#include <qtabwidget.h>
|
||||
#include <qpixmap.h>
|
||||
#include <qimage.h>
|
||||
#include <qvbox.h>
|
||||
|
||||
class TilePickerTab : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
TilePickerTab(const char *basename, int id, QWidget *parent);
|
||||
|
||||
bool save();
|
||||
int numTiles();
|
||||
|
||||
signals:
|
||||
void pick(const QImage &);
|
||||
void pickName(const QString &);
|
||||
|
||||
public slots:
|
||||
void setCurrent(const QImage &);
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *);
|
||||
QSize sizeHint() const;
|
||||
void mousePressEvent(QMouseEvent *);
|
||||
|
||||
private:
|
||||
QString filename;
|
||||
int id;
|
||||
int last_pick;
|
||||
int num;
|
||||
QPixmap pixmap;
|
||||
QImage image;
|
||||
};
|
||||
|
||||
class TilePicker : public QTabWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
TilePicker(QWidget *parent);
|
||||
|
||||
void setTile(int tilenum, const QImage &);
|
||||
|
||||
signals:
|
||||
void pick(const QImage &);
|
||||
void pickName(const QString &);
|
||||
|
||||
public slots:
|
||||
void setCurrent(const QImage &);
|
||||
void save();
|
||||
};
|
||||
|
||||
class TrivialTileEditor : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
TrivialTileEditor(QWidget *parent);
|
||||
const QImage &image() const;
|
||||
|
||||
signals:
|
||||
void edited(const QImage &);
|
||||
void pick(QRgb);
|
||||
|
||||
public slots:
|
||||
void setColor(QRgb);
|
||||
void setImage(const QImage &);
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *);
|
||||
void mousePressEvent(QMouseEvent *);
|
||||
void mouseReleaseEvent(QMouseEvent *);
|
||||
void mouseMoveEvent(QMouseEvent *);
|
||||
QSize sizeHint() const;
|
||||
QSize sizeForWidth(int) const;
|
||||
QSizePolicy sizePolicy() const;
|
||||
|
||||
private:
|
||||
void fill(QPainter &painter, QPoint p, uchar from);
|
||||
QImage img;
|
||||
QColor pen;
|
||||
int penpixel;
|
||||
void paintPoint(QPainter &painter, QPoint p);
|
||||
QPoint screenPoint(QPoint) const;
|
||||
QPoint imagePoint(QPoint) const;
|
||||
};
|
||||
|
||||
class TilePalette : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
TilePalette(QWidget *parent);
|
||||
~TilePalette();
|
||||
void setFromImage(const QImage &);
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *);
|
||||
void mousePressEvent(QMouseEvent *);
|
||||
QSize sizeHint() const;
|
||||
QSizePolicy sizePolicy() const;
|
||||
signals:
|
||||
void pick(QRgb);
|
||||
public slots:
|
||||
void setColor(QRgb);
|
||||
|
||||
private:
|
||||
int num;
|
||||
QRgb *rgb;
|
||||
};
|
||||
|
||||
class TileEditor : public QVBox
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
TileEditor(QWidget *parent);
|
||||
|
||||
const QImage &image() const;
|
||||
|
||||
signals:
|
||||
void edited(const QImage &);
|
||||
|
||||
public slots:
|
||||
void edit(const QImage &);
|
||||
|
||||
private:
|
||||
TrivialTileEditor editor;
|
||||
TilePalette palette;
|
||||
};
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user