Example #1
0
static void master_okbutton_callback (GtkWidget *widget, GtkWidget* window) {
	master_check_master_addr_prefix();

	master_addr_result = strdup_strip (gtk_entry_get_text (GTK_ENTRY (GTK_COMBO (master_addr_combo)->entry)));
	master_name_result = strdup_strip (gtk_entry_get_text (GTK_ENTRY (GTK_COMBO (master_name_combo)->entry)));

	config_set_string ("/" CONFIG_FILE "/Add Master/game", type2id (master_type));

	if (!master_addr_result || !master_name_result) {
		dialog_ok (NULL, _("You have to specify a name and an address."));
		return;
	}

	master_to_add = add_master (master_addr_result, master_name_result, master_type, NULL, TRUE, FALSE);
	if (!master_to_add) {
		dialog_ok (NULL, _("Master address \"%s\" is not valid."),
				master_addr_result);
	}
	else {

		if (master_addr_result)
			history_add (master_history_addr, master_addr_result);
		if (master_name_result)
			history_add (master_history_name, master_name_result);

		gtk_widget_destroy(window);
	}
}
Example #2
0
static void search_mode_key(enum term_key_type type, unsigned int key)
{
	switch (type) {
	case KEY_NORMAL:
		switch (key) {
		case '\r':
			if (cmdline.buf.buffer[0]) {
				search_set_regexp(cmdline.buf.buffer);
				search_next();
				history_add(&search_history, cmdline.buf.buffer, search_history_size);
			} else {
				search_next();
			}
			cmdline_clear(&cmdline);
			set_input_mode(INPUT_NORMAL);
			break;
		}
		break;
	case KEY_META:
		switch (key) {
		case 'c':
			options.case_sensitive_search = (options.case_sensitive_search + 1) % 3;
			break;
		case 'r':
			search_set_direction(current_search_direction() ^ 1);
			break;
		}
		break;
	case KEY_SPECIAL:
		break;
	case KEY_PASTE:
		break;
	}
}
Example #3
0
static void adjust_level(struct player *p, bool verbose)
{
	if (p->exp < 0)
		p->exp = 0;

	if (p->max_exp < 0)
		p->max_exp = 0;

	if (p->exp > PY_MAX_EXP)
		p->exp = PY_MAX_EXP;

	if (p->max_exp > PY_MAX_EXP)
		p->max_exp = PY_MAX_EXP;

	if (p->exp > p->max_exp)
		p->max_exp = p->exp;

	p->upkeep->redraw |= PR_EXP;

	handle_stuff(p);

	while ((p->lev > 1) &&
	       (p->exp < (player_exp[p->lev-2] * p->expfact / 100L)))
		p->lev--;


	while ((p->lev < PY_MAX_LEVEL) &&
	       (p->exp >= (player_exp[p->lev-1] * p->expfact / 100L))) {
		char buf[80];

		p->lev++;

		/* Save the highest level */
		if (p->lev > p->max_lev)
			p->max_lev = p->lev;

		if (verbose) {
			/* Log level updates */
			strnfmt(buf, sizeof(buf), "Reached level %d", p->lev);
			history_add(p, buf, HIST_GAIN_LEVEL);

			/* Message */
			msgt(MSG_LEVEL, "Welcome to level %d.",	p->lev);
		}

		effect_simple(EF_RESTORE_STAT, "0", STAT_STR, 1, 0, NULL);
		effect_simple(EF_RESTORE_STAT, "0", STAT_INT, 1, 0, NULL);
		effect_simple(EF_RESTORE_STAT, "0", STAT_WIS, 1, 0, NULL);
		effect_simple(EF_RESTORE_STAT, "0", STAT_DEX, 1, 0, NULL);
		effect_simple(EF_RESTORE_STAT, "0", STAT_CON, 1, 0, NULL);
	}

	while ((p->max_lev < PY_MAX_LEVEL) &&
	       (p->max_exp >= (player_exp[p->max_lev-1] * p->expfact / 100L)))
		p->max_lev++;

	p->upkeep->update |= (PU_BONUS | PU_HP | PU_SPELLS);
	p->upkeep->redraw |= (PR_LEV | PR_TITLE | PR_EXP | PR_STATS);
	handle_stuff(p);
}
Example #4
0
void cb_wv_notify_load_status(WebKitWebView *view, GParamSpec *pspec, Browser *b)
{
	WebKitWebFrame *frame;
	WebKitWebDataSource *source;
	WebKitNetworkRequest *request;
	SoupMessage *message;
	char *uri;

	switch (webkit_web_view_get_load_status(b->UI.view)) {
	case WEBKIT_LOAD_COMMITTED:
		uri = browser_get_uri(b);
		if (strstr(uri, "https://") == uri) {
			/* get ssl state */
			frame = webkit_web_view_get_main_frame(b->UI.view);
			source = webkit_web_frame_get_data_source(frame);
			request = webkit_web_data_source_get_request(source);
			message = webkit_network_request_get_message(request);
			b->State.ssl = soup_message_get_flags(message)
				^ SOUP_MESSAGE_CERTIFICATE_TRUSTED;
		}
		break;
	case WEBKIT_LOAD_FINISHED:
		/* add uri to history */
		if (!private_browsing && (uri = (char *)webkit_web_view_get_uri(b->UI.view))) {
			history_add(uri);
		}
		b->State.progress = 100;
		break;
	default:
		break;
	}

	/* update browser (statusbar, progress, position) */
	browser_update(b);
}
Example #5
0
parsed_line* input_process(input_state* input) {
	parsed_line* line;

	/* set term into unbuffered mode */
	reset_term(input, false);

	/* terminal i/o */
	if (!read_input(input, input->history_current->buffer)) {
		return NULL;
	}
	/* back to buffered */
	reset_term(input, true);
	putc('\n', stdout);

	if (strlen(input->history_current->buffer) == 0) {
		print_prompt();
		return NULL;
	}

	/* parse line */
	line = parse_input(input->history_current);

	history_add(input);
	input->cursor = 0;

	return line;
}
Example #6
0
static void rotateSprite(Sprite* sprite)
{
	const s32 Size = sprite->size;
	u8* buffer = (u8*)malloc(Size * Size);

	if(buffer)
	{
		{
			tic_rect rect = getSpriteRect(sprite);
			s32 r = rect.x + rect.w;
			s32 b = rect.y + rect.h;

			for(s32 y = rect.y, i = 0; y < b; y++)
				for(s32 x = rect.x; x < r; x++)
					buffer[i++] = getSheetPixel(sprite, x, y);

			for(s32 y = rect.y, j = 0; y < b; y++, j++)
				for(s32 x = rect.x, i = 0; x < r; x++, i++)
					setSheetPixel(sprite, x, y, buffer[j + (Size-i-1)*Size]);

			history_add(sprite->history);
		}

		free(buffer);
	}
}
Example #7
0
static void copyFromClipboard(Sprite* sprite)
{
	if(sprite->editPalette)
		pasteColor(sprite);

	s32 size = sprite->size * sprite->size * TIC_PALETTE_BPP / BITS_IN_BYTE;
	u8* buffer = malloc(size);

	if(buffer)
	{
		if(fromClipboard(buffer, size, true, false))
		{
			tic_rect rect = getSpriteRect(sprite);
			s32 r = rect.x + rect.w;
			s32 b = rect.y + rect.h;

			for(s32 y = rect.y, i = 0; y < b; y++)
				for(s32 x = rect.x; x < r; x++)
					setSheetPixel(sprite, x, y, tic_tool_peek4(buffer, i++));

			history_add(sprite->history);
		}

		free(buffer);

	}
}
Example #8
0
static void rotateCanvas(Sprite* sprite)
{
	u8* buffer = (u8*)malloc(CANVAS_SIZE*CANVAS_SIZE);

	if(buffer)
	{
		{
			tic_rect rect = sprite->select.rect;
			const s32 Size = rect.h * rect.w;
			s32 diff = 0;

			for(s32 y = 0, i = 0; y < rect.w; y++)
				for(s32 x = 0; x < rect.h; x++)
				{
					diff = rect.w * (x + 1) -y;
					buffer[i++] = sprite->select.front[Size - diff];
				}
			
			for (s32 i = 0; i<Size; i++)
				sprite->select.front[i] = buffer[i];
			
			rotateSelectRect(sprite);
			pasteSelection(sprite);
			history_add(sprite->history);
		}

		free(buffer);
	}
}
Example #9
0
gboolean command_search(const Arg *arg)
{
    static short dir;   /* last direction 1 forward, -1 backward*/
    const char *query;
    static gboolean newsearch = true;
    gboolean forward;

    if (arg->i == 0) {
#ifdef FEATURE_SEARCH_HIGHLIGHT
        webkit_web_view_unmark_text_matches(vb.gui.webview);
        vb.state.search_matches = 0;
        vb_update_statusbar();
#endif
        newsearch = true;
        return true;
    }

    /* copy search query for later use */
    if (arg->s) {
        /* set search direction only when the searching is started */
        dir   = arg->i > 0 ? 1 : -1;
        query = arg->s;
        /* add new search query to history and search register */
        vb_register_add('/', query);
        history_add(HISTORY_SEARCH, query, NULL);
    } else {
        /* no search phrase given - continue a previous search */
        query = vb_register_get('/');
    }

    forward = (arg->i * dir) > 0;

    if (query) {
        unsigned int count = abs(arg->i);
        if (newsearch) {
#ifdef FEATURE_SEARCH_HIGHLIGHT
            /* highlight matches if the search is started new or continued
             * after switch to normal mode which calls this function with
             * COMMAND_SEARCH_OFF */
            vb.state.search_matches = webkit_web_view_mark_text_matches(vb.gui.webview, query, false, 0);
            webkit_web_view_set_highlight_text_matches(vb.gui.webview, true);
            vb_update_statusbar();
#endif
            newsearch = false;
            /* skip first search because this is done during typing in ex
             * mode, else the search will mark the next match as active */
            if (count) {
                count -= 1;
            }
        }

        while (count--) {
            if (!webkit_web_view_search_text(vb.gui.webview, query, false, forward, true)) {
                break;
            }
        };
    }

    return true;
}
Example #10
0
/**
 * Record the player's thoughts as a note.
 *
 * This both displays the note back to the player and adds it to the game log.
 * Two fancy note types are supported: notes beginning with "/say" will be
 * written as 'Frodo says: "____"', and notes beginning with "/me" will
 * be written as 'Frodo ____'.
 */
void do_cmd_note(void) {
	/* Allocate/Initialize strings to get and format user input. */
	char tmp[200];
	char note[220];
	my_strcpy(tmp, "", sizeof(tmp));
	my_strcpy(note, "", sizeof(note));

	/* Read a line of input from the user */
	if (!get_string("Note: ", tmp, sizeof(tmp))) return;

	/* Ignore empty notes */
	if (!tmp[0] || (tmp[0] == ' ')) return;

	/* Format the note correctly, supporting some cute /me commands */
	if (strncmp(tmp, "/say ", 5) == 0)
		strnfmt(note, sizeof(note), "-- %s says: \"%s\"", op_ptr->full_name, &tmp[5]);
	else if (strncmp(tmp, "/me", 3) == 0)
		strnfmt(note, sizeof(note), "-- %s%s", op_ptr->full_name, &tmp[3]);
	else
		strnfmt(note, sizeof(note), "-- Note: %s", tmp);

	/* Display the note (omitting the "-- " prefix) */
	msg(&note[3]);

	/* Add a history entry */
	history_add(note, HISTORY_USER_INPUT, 0);
}
/* The main function of this shell
*/
int
main(int argc, char** argv, char** envp)
{
    sigignore(SIGTSTP);
    sigignore(SIGTERM);
    if (argc > 2) {
        printf("Shell: too many arguments!\n");
        return -1;
    } else if (argc == 2) {
        alarm_time = atoi(argv[1]);
        alarm_enabled = 1;
    }
    shell_init();
    int status = 0;
    env = envp;
    while (1) {
        status = respond_cycle();
        if (status == EXIT_SHELL)
            break;
        prepare_for_next_cycle();
        history_add(cmd_char);
    }
    //before_exit(status);
    fflush(stdout);
    return 0;
}
Example #12
0
void history_load(input_state* input) {
	FILE *fp;
	char *line = NULL;
	size_t len = 0;
	ssize_t read;
	history_line* hist;

	char path[PATH_MAX] = {'\0'};
	strcat(path, getenv("HOME"));
	strcat(path, "/.phistory");

	fp = fopen(path, "r");
	if (!fp)
		return;

	while ((read = getline(&line, &len, fp)) != -1) {
		if (line[read - 1] == '\n') {
			line[read - 1] = '\0';
			--read;
		}
		hist = history_add(input);
		memcpy(hist->buffer, line, read);
	}

	fclose(fp);
	free(line);
}
Example #13
0
static int
key_action_put_history (GtkWidget * wid, GdkEventKey * ent, char *d1,
									char *d2, struct session *sess)
{
	history_add (&sess->history, SPELL_ENTRY_GET_TEXT (wid));
	SPELL_ENTRY_SET_TEXT (wid, "");
	return 2;						  /* -''- */
}
Example #14
0
/**
 * Gain a new specialty ability
 * Adapted from birth.c get_player_choice -BR-
 */
void gain_specialty(void)
{
    int k;
    int pick;

    /* Find the next open entry in "specialty_order[]" */
    for (k = 0; k < MAX_SPECIALTIES; k++) {
	/* Stop at the first empty space */
	if (p_ptr->specialty_order[k] == PF_NO_SPECIALTY)
	    break;
    }

    /* Check if specialty array is full */
    if (k >= MAX_SPECIALTIES - 1) {
	msg_print("Maximum specialties known.");
	return;
    }

    /* Make one choice */
    if (gain_spec_menu(&pick)) {
	char buf[120];

	/* Add new specialty */
	p_ptr->specialty_order[k] = pick;

	/* Add it to the player flags */
	pf_on(p_ptr->pflags, pick);

	/* Increment next available slot */
	k++;

	/* Update specialties available count */
	p_ptr->new_specialties--;
	p_ptr->old_specialties = p_ptr->new_specialties;

	/* Specialty taken */
	sprintf(buf, "Gained the %s specialty.",
		abilities[pick].name);

	/* Write a note */
	history_add(buf, HISTORY_GAIN_SPECIALTY, 0);

	/* Update some stuff */
	p_ptr->update |=
	    (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS | PU_SPECIALTY | PU_TORCH);

	/* Redraw Study Status */
	p_ptr->redraw |= (PR_STUDY);
    }

    /* exit */
    return;
}
Example #15
0
int shell(FILE * f, const char * (* prompt)(void), 
		  void (* greeting)(FILE *), 
		  const struct shell_cmd * cmd_tab)
{
	char hist_buf[SIZEOF_CMD_HISTORY + SHELL_HISTORY_MAX * SHELL_LINE_MAX];
	char line[SHELL_LINE_MAX];
	struct cmd_history * history;
	int ret = 0;

	DCC_LOG(LOG_TRACE, "history_init()");
	history = history_init(hist_buf, sizeof(hist_buf), SHELL_LINE_MAX);

	if (greeting)
		greeting(f);

	do {
		char * stat;
		char * cp;

		fprintf(f, "%s", prompt());

		if (history_readline(history, f, line, SHELL_LINE_MAX) == NULL)
			return -1;

		if ((cp = shell_stripline(line)) == NULL)
			continue;

		history_add(history, cp);

		cp = line;

		ret = 0;

		while ((stat = cmd_get_next(&cp)) != NULL) {
			struct shell_cmd * cmd;

			if ((cmd = cmd_lookup(cmd_tab, stat)) == NULL) {
				fprintf(f, "Command not found!\n");
				break;
			}

			ret = cmd_exec(f, cmd, stat);

			if ((ret < 0) && (ret !=  SHELL_ABORT)) {
				fprintf(f, "Error: %d\n", -ret);
				break;
			}
			
		}
	} while (ret != SHELL_ABORT); 

	return 0;
}
Example #16
0
/*
 * Adding artifacts to the history list is trickier than other operations.
 * This is a wrapper function that gets some of the logic out of places
 * where it really doesn't belong.  Call this to add an artifact to the history
 * list or make the history entry visible--history_add_artifact will make that
 * determination depending on what object_is_known returns for the artifact.
 */
bool history_add_artifact(byte a_idx, bool known, bool found)
{
	object_type object_type_body;
	object_type *o_ptr = &object_type_body;

	char o_name[80];
	char buf[80];
	u16b type;

	/* Make fake artifact for description purposes */
	object_wipe(o_ptr);
	make_fake_artifact(o_ptr, a_idx);
	object_desc(o_name, sizeof(o_name), o_ptr,
				ODESC_PREFIX | ODESC_BASE | ODESC_SPOIL);
	strnfmt(buf, sizeof(buf), (found)?"Found %s":"Missed %s", o_name);

	/* Known objects gets different treatment */
	if (known)
	{
		/* Try revealing any existing artifact, otherwise log it */
		if (history_is_artifact_logged(a_idx))
			history_know_artifact(a_idx);
		else
			history_add(buf, HISTORY_ARTIFACT_KNOWN, a_idx);
	}
	else
	{
		if (!history_is_artifact_logged(a_idx))
		{
			type = HISTORY_ARTIFACT_UNKNOWN | (found ? 0 : HISTORY_ARTIFACT_LOST);
			history_add(buf, type, a_idx);
		}
		else
		{
			return FALSE;
		}
	}

	return TRUE;
}
Example #17
0
int main(){
	history_remove();
	history_load();
	history_add(__T("abcd"));
	assert( _tcscmp(history_get(0),__T("abcd"))==0 );
	history_add(__T("qwerrr"));
	assert( _tcscmp(history_get(0),__T("qwerrr"))==0 );
	history_add(__T("zxcv"));
	assert( _tcscmp(history_get(0),__T("zxcv"))==0 );
	history_save();
	history_load();
	history_add(__T("zxcv1"));
	assert( _tcscmp(history_get(0),__T("zxcv1"))==0 );
	assert( _tcscmp(history_get(1),__T("zxcv"))==0 );
	assert( _tcscmp(history_get(2),__T("qwerrr"))==0 );
	assert( _tcscmp(history_get(3),__T("abcd"))==0 );
	history_delete(1);
	history_save();
	history_load();
	assert( _tcscmp(history_get(0),__T("zxcv1"))==0 );
	assert( _tcscmp(history_get(1),__T("zxcv"))!=0 );
	assert( _tcscmp(history_get(2),__T("qwerrr"))==0 );
	assert( _tcscmp(history_get(3),__T("abcd"))==0 );
	history_pin(2);
	check_ni_wi();
	history_add(__T("asdff"));
	history_add(__T("asdfff"));
	history_add(__T("asdffff"));
	assert( _tcscmp(history_get(0),__T("asdffff"))==0 );
	assert( _tcscmp(history_get(1),__T("asdfff"))==0 );
	assert( _tcscmp(history_get(2),__T("qwerrr"))==0 );
	assert( _tcscmp(history_get(3),__T("asdff"))==0 );
	history_pin(3);
	check_ni_wi();
	history_unpin(2);
	check_ni_wi();
	history_pin(11);
	history_pin(13);
	check_ni_wi();
	history_pin(5);
	history_pin(6);
	check_ni_wi();
	history_delete(4);
	history_delete(5);
	check_ni_wi();
	{
		TCHAR buffer[VIEW_HISTORY*MAX_PATH];
		int len = history_to_json(buffer);
		buffer[len+1] = __T('\0');
		_tprintf(__T("\n%d,%s\n"),len,buffer);
	}
	return 0;
}
Example #18
0
static void deleteSprite(Sprite* sprite)
{
	tic_rect rect = getSpriteRect(sprite);
	s32 r = rect.x + rect.w;
	s32 b = rect.y + rect.h;

	for(s32 y = rect.y; y < b; y++)
		for(s32 x = rect.x; x < r; x++)
			setSheetPixel(sprite, x, y, sprite->color2);

	clearCanvasSelection(sprite);

	history_add(sprite->history);
}
Example #19
0
static void process_line(t_tokenline *tl)
{
	t_token *tokens;
	int words[TL_MAX_WORDS], num_words, i;

	tl->print(tl->user, NL);
	do {
		if (!tl->buf_len)
			break;
		history_add(tl);
		if (!split_line(tl, words, &num_words, FALSE))
			break;
		if (!num_words)
			break;
		if (!strcmp(tl->buf + words[0], "help")) {
			if (num_words == 1) {
				/*
				 * Nothing to tokenize: find the help entry
				 * if any so its help text can be shown.
				 */
				tokens = tl->token_levels[tl->token_level];
				for (i = 0; tokens[i].token; i++) {
					if (tokens[i].arg_type == T_ARG_HELP) {
						tl->parsed.last_token_entry = &tokens[i];
						break;
					}
				}
			} else {
				/* Tokenize with errors turned off. */
				tokenize(tl, words + 1, num_words - 1, &tokens, NULL);
			}
			show_help(tl, words, num_words);
		} else if (!strcmp(tl->buf + words[0], "history")) {
			history_show(tl);
		} else {
			if (!tokenize(tl, words, num_words, NULL, NULL))
				break;
			if (tl->callback)
				tl->callback(tl->user, &tl->parsed);
		}
	} while (FALSE);

	tl->buf[0] = 0;
	tl->buf_len = 0;
	tl->escape_len = 0;
	tl->pos = 0;
	tl->hist_step = -1;
	tl->print(tl->user, tl->prompt);
}
Example #20
0
static void
history_restore(){
	FILE *f;
	int len, i;
	if((f = fopen(history_file, "r")) == NULL) return;
	while(1){
		text_clear(line);
		if((len = fget_rune(f)) == EOF) break;
		for(i = 0; i<len; i++)
			insert_character(fget_rune(f), NULL, 0);
		history_save();
		history_add();
		hist_first++;
	}
	fclose(f);
}
Example #21
0
static void flipSpriteVert(Sprite* sprite)
{
	tic_rect rect = getSpriteRect(sprite);
	s32 r = rect.x + rect.w;
	s32 b = rect.y + rect.h/2;

	for(s32 y = rect.y, i = rect.y + rect.h - 1; y < b; y++, i--)
		for(s32 x = rect.x; x < r; x++)
		{
			u8 color = getSheetPixel(sprite, x, y);
			setSheetPixel(sprite, x, y, getSheetPixel(sprite, x, i));
			setSheetPixel(sprite, x, i, color);
		}

	history_add(sprite->history);
}
Example #22
0
static void flipSpriteHorz(Sprite* sprite)
{
	tic_rect rect = getSpriteRect(sprite);
	s32 r = rect.x + rect.w/2;
	s32 b = rect.y + rect.h;

	for(s32 y = rect.y; y < b; y++)
		for(s32 x = rect.x, i = rect.x + rect.w - 1; x < r; x++, i--)
		{
			u8 color = getSheetPixel(sprite, x, y);
			setSheetPixel(sprite, x, y, getSheetPixel(sprite, i, y));
			setSheetPixel(sprite, i, y, color);
		}

	history_add(sprite->history);
}
Example #23
0
input_state* input_init(void) {
	input_state *input;

	input = malloc(sizeof(input_state));
	input->history_current =
		input->history_first = NULL;
	input->cursor = 0;

	history_load(input);
	history_add(input);

	set_attr(input);
	reset_term(input, false);

	return input;
}
Example #24
0
void submit(char *id, char* msg, int socket )
{
  char to_ret[8];
  if( strlen(msg) < 80)
  {
    DictInsertS(messages, num_msg, msg); 
    history_add(id);
    num_msg++;
    sprintf(to_ret,"%d", 1);
  }
  else
  {
    sprintf(to_ret,"%s","Message length must be less than 80 chars");
  }
  write(socket, to_ret, sizeof(to_ret)); 
}//end submit
Example #25
0
static void deleteCanvas(Sprite* sprite)
{
	tic_rect* rect = &sprite->select.rect;
	
	s32 left = getIndexPosX(sprite) + rect->x;
	s32 top = getIndexPosY(sprite) + rect->y;
	s32 right = left + rect->w;
	s32 bottom = top + rect->h;

	for(s32 pixel_y = top; pixel_y < bottom; pixel_y++)
		for(s32 pixel_x = left; pixel_x < right; pixel_x++)
			setSheetPixel(sprite, pixel_x, pixel_y, sprite->color2);

	clearCanvasSelection(sprite);
	
	history_add(sprite->history);
}
Example #26
0
static void processDrawCanvasMouse(Sprite* sprite, s32 x, s32 y, s32 sx, s32 sy)
{
	tic_rect rect = {x, y, CANVAS_SIZE, CANVAS_SIZE};
	const s32 Size = CANVAS_SIZE / sprite->size;

	if(checkMousePos(&rect))
	{
		setCursor(tic_cursor_hand);

		s32 mx = getMouseX() - x;
		s32 my = getMouseY() - y;


		s32 brushSize = sprite->brushSize*Size;
		s32 offset = (brushSize - Size) / 2;

		mx -= offset;
		my -= offset;
		mx -= mx % Size;
		my -= my % Size;

		if(mx < 0) mx = 0;
		if(my < 0) my = 0;
		if(mx+brushSize >= CANVAS_SIZE) mx = CANVAS_SIZE - brushSize;
		if(my+brushSize >= CANVAS_SIZE) my = CANVAS_SIZE - brushSize;

		drawCursorBorder(sprite, x + mx, y + my, brushSize, brushSize);

		bool left = checkMouseDown(&rect, tic_mouse_left);
		bool right = checkMouseDown(&rect, tic_mouse_right);

		if(left || right)
		{
			sx += mx / Size;
			sy += my / Size;
			u8 color = left ? sprite->color : sprite->color2;
			s32 pixels = sprite->brushSize;

			for(s32 j = 0; j < pixels; j++)
				for(s32 i = 0; i < pixels; i++)
					setSheetPixel(sprite, sx+i, sy+j, color);

			history_add(sprite->history);
		}
	}
}
Example #27
0
/**
 * Adding artifacts to the history list is trickier than other operations.
 * This is a wrapper function that gets some of the logic out of places
 * where it really doesn't belong.  Call this to add an artifact to the history
 * list or make the history entry visible--history_add_artifact will make that
 * determination depending on what object_is_known returns for the artifact.
 */
bool history_add_artifact(struct artifact *artifact, bool known, bool found)
{
	struct object body = { 0 }, known_body = { 0 };
	struct object *fake = &body, *known_obj = &known_body;

	char o_name[80];
	char buf[80];

	assert(artifact);

	/* Make fake artifact for description purposes */
	make_fake_artifact(fake, artifact);
	fake->known = known_obj;
	known_obj->artifact = (struct artifact *) 1;
	known_obj->kind = fake->kind;
	object_desc(o_name, sizeof(o_name), fake,
				ODESC_PREFIX | ODESC_BASE | ODESC_SPOIL);
	object_wipe(known_obj);
	object_wipe(fake);
	strnfmt(buf, sizeof(buf), (found)?"Found %s":"Missed %s", o_name);

	/* Known objects gets different treatment */
	if (known) {
		/* Try revealing any existing artifact, otherwise log it */
		if (history_is_artifact_logged(artifact))
			history_know_artifact(artifact);
		else
			history_add(buf, HIST_ARTIFACT_KNOWN, artifact);
	} else {
		if (!history_is_artifact_logged(artifact)) {
			bitflag type[HIST_SIZE];
			hist_wipe(type);
			hist_on(type, HIST_ARTIFACT_UNKNOWN);
			if (!found)
				hist_on(type, HIST_ARTIFACT_LOST);
			history_add_full(type, artifact, player->depth, player->lev,
							 player->total_energy / 100, buf);
		} else {
			return false;
		}
	}

	return true;
}
Example #28
0
/**
 * Note something in the message recall or character notes file.  Lifted
 * from NPPangband, patch originally by Chris Kern.
 */
void do_cmd_note(void)
{
    char tmp[80];

    /* Default */
    my_strcpy(tmp, "", sizeof(tmp));

    /* Input */
    if (!get_string("Note: ", tmp, 80)) return;

    /* Ignore empty notes */
    if (!tmp[0] || (tmp[0] == ' ')) return;

    /* Add the note to the message recall */
    msg("Note: %s", tmp);

    /* Add a history entry */
    history_add(tmp, HISTORY_USER_INPUT, 0);
}
Example #29
0
static void
flush_line(Rune c, void* f, int v){
	if(pty_mode || f == NULL){
		append_character(v);
	}else{
		(*(void(*)(int)) f)(v);
	}
	cursor_shift(-cursor);
	erase_line();
	fflush(stderr);
	render(stdout, line->buf, utf8_of_rune);
	fflush(stdout);
	if(pty_mode || f == NULL) line->buf->c--; /* FIXME! store history without the flushing character! */
	hist_cur = hist_len - 1;
	history_save();
	if(--lines <= 0) exit(0);
	history_add();
	history_load();
}
Example #30
0
File: gvccmd.c Project: 131/gsview
void
gsview_goto_page(int pagenum)
{
    if (not_dsc())
        return;
    if (psfile.dsc->page_count == 0)
        return;
    if (pagenum > (int)psfile.dsc->page_count) {
        pagenum = psfile.dsc->page_count;
        play_sound(SOUND_NOPAGE);
    }
    else if (pagenum < 1) {
        pagenum = 1;
        play_sound(SOUND_NOPAGE);
    }
    gsview_unzoom();
    pending.pagenum = pagenum;
    pending.now = TRUE;
    history_add(pagenum);
}