Free Hero Mesh

Diff
Login
This is a mirror of the main repository for Free Hero Mesh. New tickets and changes will not be accepted at this mirror.

Differences From Artifact [51eec2ef53]:

To Artifact [7850e1bb3d]:


14
15
16
17
18
19
20

21
22
23
24
25
26
27
#include <stdlib.h>
#include <string.h>
#include "sqlite3.h"
#include "smallxrm.h"
#include "pcfont.h"
#include "quarks.h"
#include "heromesh.h"


SDL_Surface*screen;
Uint16 picture_size;
int left_margin;

static SDL_Surface*picts;
static Uint8*curpic;







>







14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include <stdlib.h>
#include <string.h>
#include "sqlite3.h"
#include "smallxrm.h"
#include "pcfont.h"
#include "quarks.h"
#include "heromesh.h"
#include "cursorshapes.h"

SDL_Surface*screen;
Uint16 picture_size;
int left_margin;

static SDL_Surface*picts;
static Uint8*curpic;
128
129
130
131
132
133
134



































































135
136
137
138
139
140
141
      ++f;
    }
    t++;
    if(!--len) return;
    pix+=8;
  }
}




































































static Uint16 decide_picture_size(int nwantsize,const Uint8*wantsize,const Uint16*havesize,int n) {
  int i,j;
  if(!nwantsize) fatal("Unable to determine what picture size is wanted\n");
  for(i=0;i<nwantsize;i++) if(havesize[j=wantsize[i]]==n) return j;
  for(i=*wantsize;i;--i) if(havesize[i]) return i;
  fatal("Unable to determine what picture size is wanted\n");







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
      ++f;
    }
    t++;
    if(!--len) return;
    pix+=8;
  }
}

const char*screen_prompt(const char*txt) {
  static char*t=0;
  int n=0;
  SDL_Rect r={0,0,screen->w,16};
  int m=r.w>>3;
  SDL_Event ev;
  if(!t) {
    t=malloc(m+2);
    if(!t) fatal("Allocation failed\n");
  }
  *t=0;
  SDL_FillRect(screen,&r,0xF1);
  r.y=16;
  r.h=1;
  SDL_FillRect(screen,&r,0xF8);
  SDL_LockSurface(screen);
  draw_text(0,0,txt,0xF1,0xFE);
  draw_text(0,8,"\xB1",0xF1,0xFB);
  SDL_UnlockSurface(screen);
  set_cursor(XC_iron_cross);
  SDL_Flip(screen);
  r.y=8;
  r.h=8;
  while(SDL_WaitEvent(&ev)) {
    switch(ev.type) {
      case SDL_QUIT:
        SDL_PushEvent(&ev);
        return 0;
      case SDL_KEYDOWN:
        SDL_FillRect(screen,&r,0xF1);
        switch(ev.key.keysym.sym) {
          case SDLK_RETURN: case SDLK_KP_ENTER:
            r.y=0;
            r.h=17;
            SDL_FillRect(screen,&r,0xF0);
            t[n]=0;
            return t;
          case SDLK_BACKSPACE: case SDLK_DELETE:
            if(n) t[n--]=0;
            break;
          case SDLK_CLEAR:
            t[n=0]=0;
            break;
          default:
            if(ev.key.keysym.sym==SDLK_u && (ev.key.keysym.mod&KMOD_CTRL)) {
              t[n=0]=0;
            } else if(ev.key.keysym.sym==SDLK_c && (ev.key.keysym.mod&KMOD_CTRL)) {
              r.y=0;
              r.h=17;
              SDL_FillRect(screen,&r,0xF0);
              return 0;
            } else if(n<m && ev.key.keysym.unicode<127 && ev.key.keysym.unicode>=32 && !(ev.key.keysym.mod&KMOD_CTRL)) {
              t[n++]=ev.key.keysym.unicode;
              t[n]=0;
            }
        }
        t[n]=0;
        SDL_FillRect(screen,&r,0xF1);
        SDL_LockSurface(screen);
        draw_text(0,8,t,0xF1,0xFF);
        draw_text(n<<3,8,"\xB1",0xF1,0xFB);
        SDL_UnlockSurface(screen);
        SDL_Flip(screen);
    }
  }
}

static Uint16 decide_picture_size(int nwantsize,const Uint8*wantsize,const Uint16*havesize,int n) {
  int i,j;
  if(!nwantsize) fatal("Unable to determine what picture size is wanted\n");
  for(i=0;i<nwantsize;i++) if(havesize[j=wantsize[i]]==n) return j;
  for(i=*wantsize;i;--i) if(havesize[i]) return i;
  fatal("Unable to determine what picture size is wanted\n");
353
354
355
356
357
358
359

360
361
362
  if(v=xrm_get_resource(resourcedb,optionquery,optionquery,2)) {
    w=strtol(v,(void*)&v,10);
    h=strtol(v,0,10);
    SDL_EnableKeyRepeat(w,h);
  } else {
    SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY,SDL_DEFAULT_REPEAT_INTERVAL);
  }

  optionquery[1]=Q_margin;
  left_margin=strtol(xrm_get_resource(resourcedb,optionquery,optionquery,2)?:"65",0,10);
}







>



421
422
423
424
425
426
427
428
429
430
431
  if(v=xrm_get_resource(resourcedb,optionquery,optionquery,2)) {
    w=strtol(v,(void*)&v,10);
    h=strtol(v,0,10);
    SDL_EnableKeyRepeat(w,h);
  } else {
    SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY,SDL_DEFAULT_REPEAT_INTERVAL);
  }
  SDL_EnableUNICODE(1);
  optionquery[1]=Q_margin;
  left_margin=strtol(xrm_get_resource(resourcedb,optionquery,optionquery,2)?:"65",0,10);
}