- Added new object - wireless router
- Added new object - PDA - Added new object - laptop - Replaced "hub" object with "hub3d" - Added the ability to edit existing text - either double click the text or select it then press 'e' or 'F2'.
This commit is contained in:
parent
84bda8c74d
commit
e10e2ce923
|
@ -15,7 +15,7 @@
|
|||
#define MAXHISTORY 50
|
||||
#define MAXCHILDREN 10
|
||||
|
||||
#define MAXOBJTYPES 19
|
||||
#define MAXOBJTYPES 30
|
||||
#define MAXOBJECTS 512
|
||||
#define MAXLINKS 512
|
||||
#define MAXLETTERVECTS 95
|
||||
|
@ -96,6 +96,7 @@
|
|||
#define S_CREATETELE (20)
|
||||
#define S_REALLYQUIT (21)
|
||||
#define S_FILLCOL (22)
|
||||
#define S_EDITTEXT (23)
|
||||
|
||||
|
||||
#define TB_POINTER (0)
|
||||
|
|
4
dist.sh
4
dist.sh
|
@ -6,12 +6,12 @@ TARFILE=${FULLNAME}.tar.gz
|
|||
WINFILE=${FULLNAME}-win32.zip
|
||||
|
||||
mkdir ${FULLNAME}
|
||||
cp Makefile.linux Makefile.freebsd Makefile.windows objects.dat buttons.dat netmapr.c netmapr.h constants.h convert.c convert.h icon.bmp verdana.ttf example.map ${FULLNAME}/
|
||||
cp README INSTALL Makefile.linux Makefile.freebsd Makefile.windows objects.dat buttons.dat netmapr.c netmapr.h constants.h convert.c convert.h icon.bmp verdana.ttf example.map ${FULLNAME}/
|
||||
tar zcvf ${TARFILE} ${FULLNAME}
|
||||
rm -rf ${FULLNAME}
|
||||
|
||||
|
||||
mkdir ${FULLNAME}
|
||||
cp objects.dat buttons.dat netmapr.exe netmapr.c netmapr.h constants.h convert.c convert.h verdana.ttf example.map icon.bmp windows_files/*.dll ${FULLNAME}/
|
||||
cp README INSTALL objects.dat buttons.dat netmapr.exe netmapr.c netmapr.h constants.h convert.c convert.h verdana.ttf example.map icon.bmp windows_files/*.dll ${FULLNAME}/
|
||||
zip -r ${WINFILE} ${FULLNAME}
|
||||
rm -rf ${FULLNAME}
|
||||
|
|
BIN
example.map
BIN
example.map
Binary file not shown.
Binary file not shown.
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 11 KiB |
114
netmapr.c
114
netmapr.c
|
@ -75,6 +75,7 @@ int startx,starty;
|
|||
int textanchor;
|
||||
char text[BUFLEN];
|
||||
int startobj,endobj;
|
||||
int updateheight;
|
||||
|
||||
char progdir[BUFLEN];
|
||||
|
||||
|
@ -249,6 +250,11 @@ int main (int argc, char **argv) {
|
|||
changestate(S_NONE);
|
||||
drawmap();
|
||||
}
|
||||
} else {
|
||||
o = textat(event.button.x, event.button.y);
|
||||
if (o != -1) {
|
||||
startedittext(o);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -419,6 +425,7 @@ int main (int argc, char **argv) {
|
|||
startx = map[curmap].obj[textanchor].x;
|
||||
starty = map[curmap].obj[textanchor].y + map[curmap].obj[textanchor].h+3;
|
||||
}
|
||||
updateheight = DEFTEXTH;
|
||||
|
||||
strcpy(text, "");
|
||||
|
||||
|
@ -831,7 +838,7 @@ int main (int argc, char **argv) {
|
|||
}
|
||||
}
|
||||
/* state dependant */
|
||||
if ((state == S_TYPETEXT) || (state == S_SAVING) || (state == S_LOADING) || (state == S_MAPNAMING)) {
|
||||
if ((state == S_TYPETEXT) || (state == S_SAVING) || (state == S_LOADING) || (state == S_MAPNAMING) || (state == S_EDITTEXT)) {
|
||||
if ((c >= FIRSTLET) && (c <= LASTLET)) {
|
||||
char temptext[2];
|
||||
sprintf(temptext, "%c", c);
|
||||
|
@ -850,6 +857,8 @@ int main (int argc, char **argv) {
|
|||
} else if (c == 13) { /* enter */
|
||||
if (state == S_TYPETEXT) {
|
||||
endtext();
|
||||
} else if (state == S_EDITTEXT) {
|
||||
endtextedit();
|
||||
} else if (state == S_SAVING) {
|
||||
savemap();
|
||||
changestate(S_NONE);
|
||||
|
@ -877,6 +886,17 @@ int main (int argc, char **argv) {
|
|||
changestate(S_ADDTEXT);
|
||||
}
|
||||
}
|
||||
if ((c == 'e') || (c == SDLK_F2)) { /* edit current text */
|
||||
if (state == S_NONE) {
|
||||
if ( (map[curmap].selecteditemtype == T_TEXT) &&
|
||||
(map[curmap].selecteditem != -1) ){
|
||||
startedittext(map[curmap].selecteditem);
|
||||
} else {
|
||||
sprintf(statustext, "Cannot edit text - no text item selected!");
|
||||
drawstatusbar();
|
||||
}
|
||||
}
|
||||
}
|
||||
if (c == 's') { /* save */
|
||||
startx = 1;
|
||||
starty = (map[curmap].height/2)-2;
|
||||
|
@ -1064,6 +1084,9 @@ void changestate(int newstate) {
|
|||
case S_TYPETEXT:
|
||||
sprintf(statustext,"Text entry mode entered.\n"); fflush(stdout);
|
||||
break;
|
||||
case S_EDITTEXT:
|
||||
sprintf(statustext,"Text edit mode entered.\n"); fflush(stdout);
|
||||
break;
|
||||
case S_MATCHSIZE:
|
||||
sprintf(statustext,"Size-matching mode entered - select object to copy size from...\n"); fflush(stdout);
|
||||
break;
|
||||
|
@ -2522,6 +2545,52 @@ int endtext(void) {
|
|||
|
||||
}
|
||||
|
||||
int endtextedit(void) {
|
||||
SDL_Rect area;
|
||||
int tw,th;
|
||||
int si;
|
||||
|
||||
/* paste old background */
|
||||
if (bg != NULL) {
|
||||
area.x = bgx;
|
||||
area.y = bgy;
|
||||
area.w = bg->w;
|
||||
area.h = bg->h;
|
||||
SDL_BlitSurface(bg,0,screen, &area);
|
||||
SDL_UpdateRect(screen, bgx, bgy, bg->w, bg->h);
|
||||
// free it
|
||||
SDL_FreeSurface(bg);
|
||||
}
|
||||
|
||||
if (strlen(text) == 0) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
si = map[curmap].selecteditem;
|
||||
|
||||
/* update text */
|
||||
strcpy(map[curmap].textob[si].text, text);
|
||||
/* anchor, x, y, height don't change */
|
||||
//map[curmap].textob[si].anchor = textanchor;
|
||||
|
||||
//map[curmap].textob[si].x = startx;
|
||||
//map[curmap].textob[si].y = starty;
|
||||
|
||||
/* calculate & update width */
|
||||
TTF_SizeText(font[map[curmap].textob[si].h], text, &tw,&th);
|
||||
map[curmap].textob[si].w = tw;
|
||||
|
||||
modified = TRUE;
|
||||
sprintf(statustext,"Updated text object #%d to '%s'\n",si, map[curmap].textob[si].text);
|
||||
drawstatusbar();
|
||||
|
||||
changestate(S_NONE);
|
||||
|
||||
drawmap();
|
||||
return FALSE;
|
||||
|
||||
}
|
||||
|
||||
int endtextmove(int x, int y) {
|
||||
int txoff,tyoff;
|
||||
|
||||
|
@ -4213,6 +4282,43 @@ int showfiledialog(void) {
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
void startedittext(int o) {
|
||||
SDL_Rect area;
|
||||
Uint32 bgcol;
|
||||
|
||||
/* edit text */
|
||||
map[curmap].selecteditem = o;
|
||||
map[curmap].selecteditemtype = T_TEXT;
|
||||
|
||||
/* start listening for text input */
|
||||
startx = map[curmap].textob[o].x;
|
||||
starty = map[curmap].textob[o].y;
|
||||
textanchor = map[curmap].textob[o].anchor;
|
||||
|
||||
strcpy(text, map[curmap].textob[o].text);
|
||||
|
||||
updateheight = map[curmap].textob[o].h;
|
||||
|
||||
bg = NULL;
|
||||
/* blank out where the old text was */
|
||||
|
||||
|
||||
if (textanchor != -1) {
|
||||
startx += map[curmap].obj[textanchor].x;
|
||||
starty += map[curmap].obj[textanchor].y;
|
||||
}
|
||||
area.x = startx;
|
||||
area.y = starty;
|
||||
area.w = map[curmap].textob[o].w;
|
||||
area.h = TTF_FontHeight(font[map[curmap].textob[o].h]);
|
||||
bgcol = SDL_MapRGB(screen->format, map[curmap].bgcol.r,map[curmap].bgcol.g,map[curmap].bgcol.b);
|
||||
SDL_FillRect(screen, &area, bgcol);
|
||||
SDL_UpdateRect(screen, area.x,area.y,area.w,area.h);
|
||||
updatetextcursor();
|
||||
|
||||
changestate(S_EDITTEXT);
|
||||
}
|
||||
|
||||
int startlink(int x, int y) {
|
||||
int linex1,liney1,linex2,liney2;
|
||||
int len;
|
||||
|
@ -4834,7 +4940,7 @@ int updateresizetextshadow(int x, int y) {
|
|||
|
||||
|
||||
//if ((map[curmap].textob[map[curmap].curtext].w + xdiff) > strlen(map[curmap].textob[map[curmap].curtext].text) * MAXLETTERWIDTH) xdiff = (strlen(map[curmap].textob[map[curmap].curtext].text) * MAXLETTERWIDTH)-map[curmap].textob[map[curmap].curtext].w;
|
||||
if ((map[curmap].textob[map[curmap].curtext].h + ydiff) > MAXLETTERHEIGHT) ydiff = MAXLETTERHEIGHT - map[curmap].textob[map[curmap].curtext].h - 1;
|
||||
if ((map[curmap].textob[map[curmap].curtext].h + ydiff) >= MAXLETTERHEIGHT) ydiff = MAXLETTERHEIGHT - map[curmap].textob[map[curmap].curtext].h - 1;
|
||||
//if ((map[curmap].textob[map[curmap].curtext].w + xdiff) < strlen(map[curmap].textob[map[curmap].curtext].text) * MINLETTERWIDTH)
|
||||
// xdiff = (strlen(map[curmap].textob[map[curmap].curtext].text) * MINLETTERWIDTH) - map[curmap].textob[map[curmap].curtext].w ;
|
||||
if ((map[curmap].textob[map[curmap].curtext].h + ydiff) < MINLETTERHEIGHT) ydiff = MINLETTERHEIGHT - map[curmap].textob[map[curmap].curtext].h ;
|
||||
|
@ -4923,7 +5029,7 @@ int updatetextcursor(void) {
|
|||
sarea.x = startx;
|
||||
sarea.y = starty;
|
||||
/* calculate text width */
|
||||
TTF_SizeText(font[DEFTEXTH], text, &tw, &th);
|
||||
TTF_SizeText(font[updateheight], text, &tw, &th);
|
||||
sarea.w = tw + CURSORWIDTH + 3;
|
||||
sarea.h = th;
|
||||
//sarea.h = DEFTEXTH;
|
||||
|
@ -4940,7 +5046,7 @@ int updatetextcursor(void) {
|
|||
temp.x = startx;
|
||||
temp.y = starty;
|
||||
temp.w = tw;
|
||||
temp.h = DEFTEXTH;
|
||||
temp.h = updateheight;
|
||||
temp.c = fgcol;
|
||||
temp.anchor = -1;
|
||||
|
||||
|
|
|
@ -198,6 +198,7 @@ int endlinkdstmove(int x, int y);
|
|||
int endlinkpointmove(int x, int y);
|
||||
int endlinksrcmove(int x, int y);
|
||||
int endtext(void);
|
||||
int endtextedit(void);
|
||||
int endtextmove(int x, int y);
|
||||
int findpointpos(link_t *l, int px, int py);
|
||||
void floodfill(SDL_Surface *dest, int x, int y, SDL_Color fillcol);
|
||||
|
@ -235,6 +236,7 @@ void initvars(void);
|
|||
void raiseselected(void);
|
||||
int savemap(void);
|
||||
int showfiledialog(void);
|
||||
void startedittext (int o);
|
||||
int startlink (int x, int y);
|
||||
int startlinkdstmove(int x, int y);
|
||||
int startlinkpointmove(int x, int y);
|
||||
|
|
BIN
netmapr.jpg
BIN
netmapr.jpg
Binary file not shown.
Before Width: | Height: | Size: 64 KiB After Width: | Height: | Size: 59 KiB |
176
objects.dat
176
objects.dat
|
@ -287,19 +287,28 @@ fill 83 73 0 0 255
|
|||
fill 40 100 90 90 90
|
||||
#
|
||||
end
|
||||
object hub 120 60
|
||||
# outline
|
||||
line 0 0 119 0 0 0 0
|
||||
line 0 0 0 59 0 0 0
|
||||
line 119 0 119 59 0 0 0
|
||||
line 0 59 119 59 0 0 0
|
||||
# fill
|
||||
fill 20 20 0 175 254
|
||||
# arrow
|
||||
line 20 30 100 30 0 0 0
|
||||
# arrowhead
|
||||
line 100 30 80 20 0 0 0
|
||||
line 100 30 80 40 0 0 0
|
||||
object hub3d 400 100
|
||||
# front
|
||||
box 0 60 300 99 170 230 255
|
||||
fill 150 80 0 150 213
|
||||
# top
|
||||
line 0 60 100 0 170 230 255
|
||||
line 100 0 399 0 170 230 255
|
||||
line 300 60 399 0 170 230 255
|
||||
fill 200 40 0 180 255
|
||||
# side
|
||||
line 300 99 399 40 170 230 255
|
||||
line 399 0 399 40 170 230 255
|
||||
fill 350 50 0 90 128
|
||||
# top right arrow
|
||||
line 80 33 95 27 0 0 0
|
||||
line 95 27 315 27 0 0 0
|
||||
line 80 33 300 33 0 0 0
|
||||
line 315 27 330 23 0 0 0
|
||||
line 300 33 285 39 0 0 0
|
||||
line 330 23 340 31 0 0 0
|
||||
line 285 39 340 31 0 0 0
|
||||
fill 255 30 250 250 250
|
||||
end
|
||||
object terminalserver 120 120
|
||||
# triangle
|
||||
|
@ -465,29 +474,122 @@ object bluebox 120 120
|
|||
box 0 0 119 119 0 0 0
|
||||
fill 50 50 0 0 255
|
||||
end
|
||||
object switch 120 120
|
||||
object pda 100 210
|
||||
# outline
|
||||
line 0 0 119 0 0 0 0
|
||||
line 0 0 0 119 0 0 0
|
||||
line 119 0 119 119 0 0 0
|
||||
line 0 119 119 119 0 0 0
|
||||
# fill
|
||||
fill 20 20 0 175 254
|
||||
# arrows
|
||||
line 60 24 100 24 0 0 0
|
||||
line 20 48 60 48 0 0 0
|
||||
line 60 72 100 72 0 0 0
|
||||
line 20 96 60 96 0 0 0
|
||||
# arrowhead #1
|
||||
line 95 14 100 24 0 0 0
|
||||
line 95 34 100 24 0 0 0
|
||||
# arrowhead #2
|
||||
line 20 48 30 38 0 0 0
|
||||
line 20 48 30 58 0 0 0
|
||||
# arrowhead #3
|
||||
line 95 62 100 72 0 0 0
|
||||
line 95 82 100 72 0 0 0
|
||||
# arrowhead #4
|
||||
line 20 96 30 86 0 0 0
|
||||
line 20 96 30 106 0 0 0
|
||||
#box 0 0 99 205 0 0 0
|
||||
line 10 0 89 0 0 0 0
|
||||
line 89 0 99 10 0 0 0
|
||||
line 99 10 99 195 0 0 0
|
||||
line 99 195 89 205 0 0 0
|
||||
line 89 205 10 205 0 0 0
|
||||
line 10 205 0 195 0 0 0
|
||||
line 0 195 0 10 0 0 0
|
||||
line 0 10 10 0 0 0 0
|
||||
# screen
|
||||
box 10 15 90 159 0 0 0
|
||||
fill 50 100 0 0 255
|
||||
# joystick
|
||||
box 40 170 60 190 0 0 0
|
||||
fill 50 180 250 250 250
|
||||
# buttons - left
|
||||
box 15 170 40 180 0 0 0
|
||||
fill 25 175 250 250 250
|
||||
box 20 183 40 190 0 0 0
|
||||
fill 30 188 250 250 250
|
||||
# buttons - right
|
||||
box 60 170 85 180 0 0 0
|
||||
fill 73 175 250 250 250
|
||||
box 60 183 80 190 0 0 0
|
||||
fill 73 188 250 250 250
|
||||
# outline - fill
|
||||
fill 10 180 190 190 190
|
||||
# lights
|
||||
box 75 0 80 7 0 255 0
|
||||
fill 77 5 0 255 0
|
||||
box 65 0 70 7 255 0 0
|
||||
fill 67 5 255 0 0
|
||||
end
|
||||
object laptop 150 111
|
||||
# monitor
|
||||
box 50 10 139 80 90 90 90
|
||||
box 60 20 130 70 90 90 90
|
||||
fill 80 15 0 0 0
|
||||
fill 80 50 0 0 255
|
||||
# base
|
||||
line 50 80 15 110 90 90 90
|
||||
line 139 80 104 110 90 90 90
|
||||
line 15 110 104 110 90 90 90
|
||||
# keyboard - top
|
||||
line 55 85 120 85 90 90 90
|
||||
# keyboard - sides
|
||||
line 55 85 37 100 90 90 90
|
||||
line 120 85 102 100 90 90 90
|
||||
# keyboard - bottom
|
||||
line 37 100 102 100 90 90 90
|
||||
# keyboard - fill
|
||||
fill 80 92 180 180 180
|
||||
# keyboard - keys
|
||||
line 65 85 47 100 90 90 90
|
||||
line 75 85 57 100 90 90 90
|
||||
line 85 85 67 100 90 90 90
|
||||
line 95 85 77 100 90 90 90
|
||||
line 105 85 87 100 90 90 90
|
||||
line 115 85 97 100 90 90 90
|
||||
# keyboard - keys - horz
|
||||
line 46 92 111 92 90 90 90
|
||||
# base - fill
|
||||
fill 80 102 0 0 0
|
||||
end
|
||||
object accesspoint 400 250
|
||||
# front
|
||||
box 0 210 300 249 170 230 255
|
||||
fill 150 230 0 150 213
|
||||
# top
|
||||
# (gaps for antenna)
|
||||
#line 100 150 399 150 170 230 255
|
||||
line 100 150 135 150 170 230 255
|
||||
line 150 150 260 150 170 230 255
|
||||
line 275 150 399 150 170 230 255
|
||||
line 0 210 100 150 170 230 255
|
||||
line 300 210 399 150 170 230 255
|
||||
# left antenna
|
||||
line 135 50 135 180 170 230 255
|
||||
line 150 45 150 175 170 230 255
|
||||
# left antenna - top
|
||||
line 135 50 135 40 170 230 255
|
||||
line 135 40 140 35 170 230 255
|
||||
line 140 35 145 35 170 230 255
|
||||
line 145 35 150 40 170 230 255
|
||||
line 150 40 150 45 170 230 255
|
||||
# left antenna - bottom
|
||||
line 135 180 145 180 170 230 255
|
||||
line 145 180 150 175 170 230 255
|
||||
# left anetnna - fill
|
||||
fill 141 100 0 150 213
|
||||
# left antenna - bottom (overwrite)
|
||||
line 135 180 145 180 0 150 213
|
||||
line 145 180 150 175 0 150 213
|
||||
# right antenna
|
||||
line 260 50 260 180 170 230 255
|
||||
line 275 45 275 175 170 230 255
|
||||
# right antenna - top
|
||||
line 260 50 260 40 170 230 255
|
||||
line 260 40 265 35 170 230 255
|
||||
line 265 35 270 35 170 230 255
|
||||
line 270 35 275 40 170 230 255
|
||||
line 275 40 275 45 170 230 255
|
||||
# right antenna - bottom
|
||||
line 260 180 270 180 170 230 255
|
||||
line 270 180 275 175 170 230 255
|
||||
# right anetnna - fill
|
||||
fill 266 100 0 150 213
|
||||
# right antenna - bottom (overwrite)
|
||||
line 260 180 270 180 0 150 213
|
||||
line 270 180 275 175 0 150 213
|
||||
# fill top
|
||||
fill 200 190 0 180 255
|
||||
# side
|
||||
line 300 249 399 190 170 230 255
|
||||
line 399 150 399 190 170 230 255
|
||||
fill 350 200 0 90 128
|
||||
end
|
||||
|
|
28
todo.txt
28
todo.txt
|
@ -1,18 +1,4 @@
|
|||
IMPLEMMENT ORDER:
|
||||
add alt+leftdrag for systems with no middle button!
|
||||
|
||||
add objects:
|
||||
vpn concentrator
|
||||
ids sensor
|
||||
|
||||
bug: load map, create new object, text item teleports to it!
|
||||
might have just been old save format...
|
||||
add checking to load function
|
||||
text.anchor > numobjects?
|
||||
link.srcobj > numobjects?
|
||||
link.dstobj > numobjects?
|
||||
|
||||
make objectbox scrollable!!
|
||||
|
||||
crashes on getrgb under solaris (depth = 24, truecolor)
|
||||
ok on freebsd (depth = 16, truecolor)
|
||||
|
@ -28,18 +14,18 @@ IMPLEMMENT ORDER:
|
|||
implement snap-to-grid
|
||||
|
||||
ability to edit already existing text
|
||||
set "text" from existing object
|
||||
set "fgcol" from existing object
|
||||
set "text size" from existing object
|
||||
delete existing object
|
||||
go into text entry mode
|
||||
create new one
|
||||
|
||||
preferred text size
|
||||
|
||||
add objects:
|
||||
add generic objects ("shapes.dat"):
|
||||
(force alpha = 255)
|
||||
box
|
||||
circle
|
||||
rounded box
|
||||
|
||||
add export to jpg function
|
||||
|
||||
add import functions:
|
||||
SVG
|
||||
xml
|
||||
|
||||
|
|
Loading…
Reference in New Issue