Esempio n. 1
0
void campaign_tree_view::OnContextMenu(CWnd* pWnd, CPoint point) 
{
	int i;
	CMenu menu, *popup;
	CPoint p = point;
	CClientDC dc(this);

	OnPrepareDC(&dc);
	dc.DPtoLP(&p);

	ScreenToClient(&p);
	for (i=0; i<Campaign.num_missions; i++)
		if (Elements[i].box.PtInRect(p))
			break;

	if (i < Campaign.num_missions) {  // clicked on a mission
		Context_mission = i;
		if (menu.LoadMenu(IDR_CPGN_VIEW_ON)) {
			popup = menu.GetSubMenu(0);
			ASSERT(popup);
			popup->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, point.x, point.y, this);
		}

	} else {
		Context_mission = query_level(p);
		if ((Context_mission >= 0) && (Context_mission < total_levels))
			if (menu.LoadMenu(IDR_CPGN_VIEW_OFF)) {
				popup = menu.GetSubMenu(0);
				ASSERT(popup);
				popup->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, point.x, point.y, this);
			}
	}
}
Esempio n. 2
0
void campaign_tree_view::OnMouseMove(UINT nFlags, CPoint point)
{
	int i, level, pos, x, y;
	CSize draw_size;
	CRect rect, r1;
	CClientDC dc(this);

	OnPrepareDC(&dc);
	dc.DPtoLP(&point);
	if ((Mission_dragging >= 0) || (Mission_dropping >= 0)) {
		if (GetCapture() != this) {
			rect = Dragging_rect;
			dc.LPtoDP(&rect);
			dc.DrawDragRect(rect, CSize(0, 0), rect, Last_draw_size);
			Mission_dragging = Mission_dropping = -1;

		} else {
			for (i=0; i<Campaign.num_missions; i++)
				if (Elements[i].box.PtInRect(point))
					break;

			if ((i < Campaign.num_missions) && (Mission_dropping < 0)) {  // on a mission box?
				draw_size = CSize(4, 4);
				rect = Elements[i].box;

			} else {
				level = query_level(point);
				pos = query_pos(point);
				if ((level < 0) || (pos < 0)) {  // off table?
					draw_size = CSize(0, 0);
					rect = Dragging_rect;

				} else {
					draw_size = CSize(2, 2);
					for (i=0; i<Campaign.num_missions; i++)
						if ((Campaign.missions[i].level == level) && (Campaign.missions[i].pos + 1 == pos)) {
							pos = query_alternate_pos(point);
							break;
						}

					x = pos * CELL_WIDTH / 2 - Bx / 2;
					y = level * LEVEL_HEIGHT + LEVEL_HEIGHT / 2 - By / 2;
					rect.SetRect(x, y, x + Bx, y + By);
				}
			}

			r1 = rect;
			dc.LPtoDP(&r1);
			dc.LPtoDP(&Dragging_rect);
			dc.DrawDragRect(r1, draw_size, Dragging_rect, Last_draw_size);
			Dragging_rect = rect;
			Last_draw_size = draw_size;
		}
	}

	CScrollView::OnMouseMove(nFlags, point);
}
Esempio n. 3
0
string query_title(object player) {
  int lvl;
 
  lvl = query_level(player);
  if (lvl < 5) return "apprentice fighter";
  if (lvl < 10) return "novice fighter";
  if (lvl < 20) return "experienced fighter";
  if (lvl < 30) return "the proficent swordsman";
  if (lvl < 40) return "the excellent swordsman";
  if (lvl < 50) return "the expert swordsman";
  if (lvl < 60) return "the master swordsman";
  return "the weapon master";
}
Esempio n. 4
0
int cola_query(cola_t c, cola_key_t key, int *result)
{
	cola_key_t lo = 0, hi = 1;
	unsigned int i;

	for(i = 0; c->c_nelem >= (1U << i); i++) {
		if ( !query_level(c, key, i, result, &lo, &hi) )
			return 0;
		if ( *result )
			return 1;
	}

	*result = 0;
	return 1;
}
Esempio n. 5
0
void campaign_tree_view::drop_mission(int m, CPoint point)
{
	char name[MAX_FILENAME_LEN + 1];
	int i, item, level, pos;
	cmission *cm;
	mission a_mission;
	CListBox *listbox;

	level = query_level(point);
	pos = query_pos(point);
	Assert((level >= 0) && (pos >= 0));  // this should be impossible

	listbox = (CListBox *) &Campaign_tree_formp->m_filelist;
	item = listbox->GetCurSel();
	if (item == LB_ERR) {
		MessageBox("Select a mission from listbox to add.", "Error");
		return;
	}

	if (listbox->GetTextLen(item) > MAX_FILENAME_LEN) {
		char buf[256];

		sprintf(buf, "Filename is too long.  Must be %d or less characters.", MAX_FILENAME_LEN);
		MessageBox(buf, "Error");
		return;  // filename is too long.  Would overflow our buffer
	}

	// grab the filename selected from the listbox
	listbox->GetText(item, name);

	if (Campaign.num_missions >= MAX_CAMPAIGN_MISSIONS) {  // Can't add any more
		MessageBox("Too many missions.  Can't add more to Campaign.", "Error");
		return;
	}

	if (!level && (get_root_mission() >= 0)) {
		MessageBox("Only 1 mission may be in the top level");
		return;
	}

	// check the number of players in a multiplayer campaign against the number of players
	// in the mission that was just dropped
	if ( Campaign.type != CAMPAIGN_TYPE_SINGLE ) {
		get_mission_info(name, &a_mission);
		if ( !(a_mission.game_type & MISSION_TYPE_MULTI) ) {
			char buf[256];

			sprintf(buf, "Mission \"%s\" is not a multiplayer mission", name);
			MessageBox(buf, "Error");
			return;
		}

		if (Campaign.num_players != 0) {
			if (Campaign.num_players != a_mission.num_players) {
				char buf[512];

				sprintf(buf, "Mission \"%s\" has %d players.  Campaign has %d players.  Campaign will not play properly in FreeSpace", name, a_mission.num_players, Campaign.num_players );
				MessageBox(buf, "Warning");
			}

		} else {
			Campaign.num_players = a_mission.num_players;
		}
	}

	Elements[Campaign.num_missions].from_links = Elements[Campaign.num_missions].to_links = 0;
	cm = &(Campaign.missions[Campaign.num_missions++]);
	cm->name = strdup(name);
	cm->formula = Locked_sexp_true;
	cm->num_goals = -1;
	cm->notes = NULL;
	cm->briefing_cutscene[0] = 0;
	for (i=0; i<Campaign.num_missions - 1; i++)
		if ((Campaign.missions[i].level == level) && (Campaign.missions[i].pos + 1 == pos)) {
			pos = query_alternate_pos(point);
			break;
		}

	cm->level = level;
	cm->pos = pos - 1;
	correct_position(Campaign.num_missions - 1);
	sort_links();
	SetScrollSizes(MM_TEXT, CSize(total_width * CELL_WIDTH, total_levels * LEVEL_HEIGHT));
	Invalidate();

	// update and reinitialize dialog items
	if ( Campaign.type != CAMPAIGN_TYPE_SINGLE ) {
		Campaign_tree_formp->update();
		Campaign_tree_formp->initialize(0);
	}

	listbox->DeleteString(item);
	Campaign_modified = 1;
	return;
}
Esempio n. 6
0
void campaign_tree_view::OnLButtonUp(UINT nFlags, CPoint point) 
{
	int i, j, z, level, pos;
	CClientDC dc(this);

	OnPrepareDC(&dc);
	dc.DPtoLP(&point);
	if (Mission_dropping >= 0) {  // dropping a new mission into campaign?
		z = Mission_dropping;
		Mission_dropping = -1;
		if (GetCapture() == this) {
			ReleaseCapture();
			dc.LPtoDP(&Dragging_rect);
			dc.DrawDragRect(Dragging_rect, CSize(0, 0), Dragging_rect, Last_draw_size);

			drop_mission(z, point);
			return;
		}

	} else if (Mission_dragging >= 0) {  // moving position of a mission?
		z = Mission_dragging;
		Mission_dragging = -1;
		if (GetCapture() == this) {
			ReleaseCapture();
			dc.LPtoDP(&Dragging_rect);
			dc.DrawDragRect(Dragging_rect, CSize(0, 0), Dragging_rect, Last_draw_size);
			for (i=0; i<Campaign.num_missions; i++)
				if (Elements[i].box.PtInRect(point)) {  // see if released on another mission
					if (i == z)  // released on the same mission?
						return;

					for (j=0; j<Total_links; j++)
						if ((Links[j].from == z) && (Links[j].to == i))
							return;  // already linked

					if (Total_links >= MAX_CAMPAIGN_TREE_LINKS) {
						MessageBox("Too many links exist.  Can't add any more.");
						return;
					}

					if (Campaign.missions[z].level >= Campaign.missions[i].level) {
						MessageBox("A branch can only be set to a mission on a lower level");
						return;
					}

					add_link(z, i);
					return;
				}

			// at this point, we are dragging a mission to a new place
			level = query_level(point);
			pos = query_pos(point);
			if ((level < 0) || (pos < 0))
				return;

			if (!level && (get_root_mission() >= 0)) {
				MessageBox("Can't move mission to this level.  There is already a top level mission");
				return;
			}

			for (i=0; i<Campaign.num_missions; i++)
				if ((Campaign.missions[i].level == level) && (Campaign.missions[i].pos + 1 == pos)) {
					pos = query_alternate_pos(point);
					break;
				}

			for (i=0; i<Total_links; i++)
				if (Links[i].to == z)
					if (level <= Campaign.missions[Links[i].from].level) {
						MessageBox("Can't move mission to that level, as it would be\n"
							"above a parent mission", "Error");

						return;
					}

			Campaign.missions[z].level = level;
			Campaign.missions[z].pos = pos - 1;
			correct_position(z);
			sort_links();
			SetScrollSizes(MM_TEXT, CSize(total_width * CELL_WIDTH, total_levels * LEVEL_HEIGHT));
			Invalidate();
			Campaign_modified = 1;
			return;
		}
	}
	
	CScrollView::OnLButtonUp(nFlags, point);
}
Esempio n. 7
0
inherit MONSTER;

create(){
    ::create();
    set("short", "a furry little monkey");
    set("long", "This is a cute little monkey.\n");
    set("id", ({ "#MONKEY#", "#BLAH#", "monkey" }) );
    set("race", "monkey");
    set_name("monkey");
    set_level(2);
    set_alignment("cg") ;
    set("damage", ({ 1, 3 }) );
    set("weapon_name", "fists");
    set("chat_chance", 9) ;
    set("chat_output", ({
      "The monkey does something funny.\n",
      "The monkey does a human trick.\n",
      "The monkey picks at his butt.\n",
      "The monkey picks something out of his hair and eats it.\n",
      "The monkey climbs all around.\n",
      "The monkey dances for you.\n",
    }) );
    credit(query_level() * 20); 
    set("att_chat_output", ({ 
      "The monkey chitters at you angrily.\n",
    }) );
    set_verbs( ({ "punch at", "attack", "swing at" }) );
    set_verbs2( ({ "punches at", "attacks", "swings at" }) );
}