CGPatternRef Pattern::createPlatformPattern(const AffineTransform& userSpaceTransformation) const
{
    IntRect tileRect = tileImage()->rect();

    AffineTransform patternTransform = userSpaceTransformation * m_patternSpaceTransformation;
    patternTransform.scaleNonUniform(1, -1);
    patternTransform.translate(0, -tileRect.height());

    // If we're repeating in both directions, we can use image-backed patterns
    // instead of custom patterns, and avoid tiling-edge pixel cracks.
    if (m_repeatX && m_repeatY)
        return wkCGPatternCreateWithImageAndTransform(tileImage()->getCGImageRef(), patternTransform, wkPatternTilingConstantSpacing);

    // If FLT_MAX should also be used for xStep or yStep, nothing is rendered. Using fractions of FLT_MAX also
    // result in nothing being rendered.
    // INT_MAX is almost correct, but there seems to be some number wrapping occurring making the fill
    // pattern is not filled correctly.
    // To make error of floating point less than 0.5, we use the half of the number of mantissa of float (1 << 22).
    CGFloat xStep = m_repeatX ? tileRect.width() : (1 << 22);
    CGFloat yStep = m_repeatY ? tileRect.height() : (1 << 22);

    // The pattern will release the CGImageRef when it's done rendering in patternReleaseCallback
    CGImageRef platformImage = CGImageRetain(tileImage()->getCGImageRef());

    const CGPatternCallbacks patternCallbacks = { 0, patternCallback, patternReleaseCallback };
    return CGPatternCreate(platformImage, tileRect, patternTransform, xStep, yStep, kCGPatternTilingConstantSpacing, TRUE, &patternCallbacks);
}
Ejemplo n.º 2
0
void cPict::draw(){
	RGBColor store_color;
	Rect rect = frame;
	GrafPtr cur_port;
	GetPort(&cur_port);
	SetPortWindowPort(parent->win);
	
	if(!visible){ // Erase it
		InsetRect(&rect, -3, -3);
		tileImage(rect,bg_gworld,bg[parent->bg]);
		return;
	}
	if(picNum < 0) { // Just fill with black
		GetForeColor(&store_color);
		ForeColor(blackColor);
		PaintRect(&rect);
		RGBForeColor(&store_color);
		return;
	}
	GetBackColor(&store_color);
	BackColor(whiteColor);
	
	drawPict()[picType](picNum,rect);
	if(drawFramed) drawFrame(2,0);
	SetPort(cur_port);
}
SkShader* Pattern::platformPattern(const AffineTransform&)
{
    if (m_pattern)
        return m_pattern;

    if (!tileImage())
        return 0;
    SkBitmapRef* ref = tileImage()->nativeImageForCurrentFrame();
    if (!ref)
        return 0;
    m_pattern = SkShader::CreateBitmapShader(ref->bitmap(),
                                             toTileMode(m_repeatX),
                                             toTileMode(m_repeatY));
    m_pattern->setLocalMatrix(m_patternSpaceTransformation);
    return m_pattern;
}
Ejemplo n.º 4
0
QBrush Pattern::createPlatformPattern(const TransformationMatrix& transform) const
{
    QPixmap* pixmap = tileImage()->nativeImageForCurrentFrame();
    if (!pixmap)
        return QBrush();

    QBrush brush(*pixmap);
    brush.setMatrix(transform);

    return brush;
}
Ejemplo n.º 5
0
cairo_pattern_t* Pattern::createPlatformPattern(const AffineTransform& patternTransform) const
{
    cairo_surface_t* surface = tileImage()->nativeImageForCurrentFrame();
    if (!surface)
        return 0;

    cairo_pattern_t* pattern = cairo_pattern_create_for_surface(surface);
    const cairo_matrix_t* pattern_matrix = reinterpret_cast<const cairo_matrix_t*>(&patternTransform);
    cairo_pattern_set_matrix(pattern, pattern_matrix);
    if (m_repeatX || m_repeatY)
        cairo_pattern_set_extend(pattern, CAIRO_EXTEND_REPEAT);
    return pattern;
}
Ejemplo n.º 6
0
void drawCursor()
{
	Entity *e;

	if (cursor.type == TILES)
	{
		drawImage(tileImage(cursor.tileID), cursor.x, cursor.y, FALSE, 255);

		drawImage(tileImage(BLANK_TILE), cursor.x, cursor.y, FALSE, 255);
	}

	else
	{
		e = isSpaceEmpty(&cursor.entity);

		if (isValidOnMap(&cursor.entity) == 0 || e != NULL)
		{
			drawBox(game.screen, cursor.x, cursor.y, cursor.entity.w, cursor.entity.h, 255, 0, 0);
		}

		if (e != NULL)
		{
			setStatusPanelMessage("%s : %d %d", (strlen(e->objectiveName) == 0 ? e->name : e->objectiveName), (int)e->x, (int)e->y);
		}

		else
		{
			setStatusPanelMessage("");
		}

		cursor.entity.x = getMapStartX() + cursor.x;
		cursor.entity.y = getMapStartY() + cursor.y;

		self = &cursor.entity;

		self->draw();
	}
}
Ejemplo n.º 7
0
CGPatternRef Pattern::createPlatformPattern(const TransformationMatrix& userSpaceTransformation) const
{
    IntRect tileRect = tileImage()->rect();

    TransformationMatrix patternTransform = m_patternSpaceTransformation;
    patternTransform.multiply(userSpaceTransformation);
    patternTransform.scaleNonUniform(1, -1);
    patternTransform.translate(0, -tileRect.height());

    // If FLT_MAX should also be used for xStep or yStep, nothing is rendered. Using fractions of FLT_MAX also
    // result in nothing being rendered.
    // INT_MAX is almost correct, but there seems to be some number wrapping occuring making the fill
    // pattern is not filled correctly. 
    // So, just pick a really large number that works. 
    float xStep = m_repeatX ? tileRect.width() : (100000000.0f);
    float yStep = m_repeatY ? tileRect.height() : (100000000.0f);

    // The pattern will release the tile when it's done rendering in patternReleaseCallback
    tileImage()->ref();

    const CGPatternCallbacks patternCallbacks = { 0, patternCallback, patternReleaseCallback };
    return CGPatternCreate(tileImage(), tileRect, patternTransform, xStep, yStep,
        kCGPatternTilingConstantSpacing, TRUE, &patternCallbacks);
}
Ejemplo n.º 8
0
cairo_pattern_t* Pattern::createPlatformPattern(const AffineTransform&) const
{
    NativeImageCairo* image = tileImage()->nativeImageForCurrentFrame();
    if (!image)
        return 0;

    cairo_pattern_t* pattern = cairo_pattern_create_for_surface(image->surface());

    // cairo merges patter space and user space itself
    cairo_matrix_t matrix = m_patternSpaceTransformation;
    cairo_matrix_invert(&matrix);
    cairo_pattern_set_matrix(pattern, &matrix);

    if (m_repeatX || m_repeatY)
        cairo_pattern_set_extend(pattern, CAIRO_EXTEND_REPEAT);
    return pattern;
}
Ejemplo n.º 9
0
bool EditorObject::build(ResourceFile & resources)
{
    // create the container to hold the graphic ids
    delete m_compiledGraphics;
    m_compiledGraphics = new Array3<QString>(tileCountX(), tileCountY(), layerCount());

    Array3< QList<QImage> * > animations(tileCountX(), tileCountY(), layerCount());
    // initialize animation list
    for (int z=0; z<layerCount(); z++) {
        for (int y=0; y<tileCountY(); ++y) {
            for (int x=0; x<tileCountX(); ++x) {
                animations.set(x,y,z,new QList<QImage>());
            }
        }
    }

    // find out the greatest frames per second
    int fps = 0;
    for (int layerIndex=0; layerIndex<m_graphics.size(); ++layerIndex) {
        QList<ObjectGraphic *> * layer = m_graphics.at(layerIndex);
        for (int i=0; i<layer->size(); ++i) {
            ObjectGraphic * graphicInstance = layer->at(i);
            if (graphicInstance->graphic->framesPerSecond() > fps)
                fps = graphicInstance->graphic->framesPerSecond();
        }
    }

    // for each animation frame
    int frame = 0;
    while (true) {
        if (frame > 0) {
            // check if the animation has looped yet.
            bool firstFrame = true;
            for (int layerIndex=0; layerIndex<m_graphics.size(); ++layerIndex) {
                QList<ObjectGraphic *> * layer = m_graphics.at(layerIndex);
                for (int i=0; i<layer->size(); ++i) {
                    ObjectGraphic * graphicInstance = layer->at(i);
                    if ((frame+1) % graphicInstance->graphic->frameCount() != 0) {
                        firstFrame = false;
                        break;
                    }
                }
                if (! firstFrame)
                    break;
            }

            // this means all animations have looped and we're done
            // collecting frames
            if (firstFrame)
                break;
        }

        for (int z=0; z<layerCount(); ++z) {
            // render the layer once into a QImage
            QImage layerImage(tileCountX() * Tile::sizeInt, tileCountY() * Tile::sizeInt, QImage::Format_ARGB32);
            layerImage.fill(Qt::transparent);
            QPainter layerPainter(&layerImage);
            render(layerPainter, z, frame, fps);

            // for each tile, draw that tile into a different QImage
            for (int y=0; y<tileCountY(); ++y) {
                for (int x=0; x<tileCountX(); ++x) {
                    QImage tileImage(Tile::sizeInt, Tile::sizeInt, QImage::Format_ARGB32);
                    tileImage.fill(Qt::transparent);
                    QPainter p(&tileImage);
                    p.drawImage(0, 0, layerImage, x * Tile::sizeInt, y * Tile::sizeInt, Tile::sizeInt, Tile::sizeInt);

                    QList<QImage> * frames = animations.get(x,y,z);
                    frames->append(tileImage);
                }
            }
        }

        ++frame;
    }
    int frameCount = frame;

    // create a spritesheet for each tile
    for (int z=0; z<layerCount(); ++z) {
        for (int y=0; y<tileCountY(); ++y) {
            for (int x=0; x<tileCountX(); ++x ) {
                // create the spritesheet
                QList<QImage> * frames = animations.get(x,y,z);
                QImage spritesheet(Tile::sizeInt * frameCount, Tile::sizeInt, QImage::Format_ARGB32);
                spritesheet.fill(Qt::transparent);
                QPainter p(&spritesheet);
                for (int i=0; i<frameCount; ++i)
                    p.drawImage(i * Tile::sizeInt, 0, frames->at(i % frames->size()));

                // create the binary data
                QByteArray tile;
                // magic character
                tile.append("G");

                int codeVersion = 1;
                tile.append((char *) &codeVersion, 4);

                int graphicType = Graphic::gtAnimation;
                tile.append((char *) &graphicType, 4);

                int storageType = Graphic::stPNG;
                tile.append((char *) &storageType, 4);

                // color key: hardcode magenta
                char red = 255;
                char green = 0;
                char blue = 255;
                tile.append(&red, 1);
                tile.append(&green, 1);
                tile.append(&blue, 1);

                tile.append((char *) &frameCount, 4);
                tile.append((char *) &fps, 4);

                // frame width and height
                tile.append((char *) &Tile::sizeInt, 4);
                tile.append((char *) &Tile::sizeInt, 4);

                // save spritesheet into memory
                QByteArray imageData;
                QBuffer buffer(&imageData);
                buffer.open(QIODevice::WriteOnly);
                spritesheet.save(&buffer, "PNG");

                int imageDataSize = imageData.size();
                tile.append((char *) &imageDataSize, 4);

                tile.append(imageData);

                // come up with a name
                QString dash = "-";
                QString ext = ".ani";
                QString graphicName = m_name + dash + QString::number(x) +
                    dash + QString::number(y) + dash + QString::number(z) + ext;

                resources.updateResource(graphicName.toStdString(), tile.constData(), tile.size());
                m_compiledGraphics->set(x,y,z,graphicName);
            }
        }
    }

    // cleanup animation list
    for (int z=0; z<layerCount(); z++) {
        for (int y=0; y<tileCountY(); ++y) {
            for (int x=0; x<tileCountX(); ++x) {
                delete animations.get(x,y,z);
            }
        }
    }

    return true;
}
Ejemplo n.º 10
0
void draw_shop_graphics(bool pressed,Rect clip_area_rect)
// mode 1 - drawing dark for button press
{
	Rect area_rect,item_info_from = {11,42,24,56};
	
	Rect face_rect = {6,6,38,38};
	Rect title_rect = {15,48,42,260};
	Rect dest_rect,help_from = {85,36,101,54};
	short faces[13] = {1,1,1,42,43, 1,1,1,1,1, 44,44,44};
	
	short i,what_chosen;
	RGBColor c[7] = {{0,0,0},{0,0,32767},{0,0,14535},{0,0,26623},{0,0,59391},
	{0,40959,0},{0,24575,0}};
	Rect shopper_name = {44,6,56,260};
	short current_pos;
	
	short cur_cost,what_magic_shop,what_magic_shop_item;
	char cur_name[60];
	char cur_info_str[60];
char *cost_strs[] = {"Extremely Cheap","Very Reasonable","Pretty Average","Somewhat Pricey",
	"Expensive","Exorbitant","Utterly Ridiculous"};
	GrafPtr old_port;
	cItemRec base_item;
	
	if (overall_mode != 21) {
		return;
		}
	
	
	GetPort(&old_port);
	SetPort(talk_gworld);
	TextFont(dungeon_font_num);
	TextSize(18);
	TextFace(0);

	if (pressed) {
		ClipRect(&clip_area_rect);	
		}

	GetPortBounds(talk_gworld,&area_rect);
	FrameRect(&area_rect);
	InsetRect(&area_rect,1,1);
	tileImage(area_rect,bg_gworld,bg[12]);

	FrameRect(&shop_frame);
	
	// Place store icon
	if (!pressed) { 
		SetPort(GetWindowPort(mainPtr));
		i = faces[store_shop_type];
		draw_dialog_graphic( talk_gworld, face_rect, i, PICT_TALK, false,1);
		SetPort( talk_gworld);
	}


	// Place name of store and shopper name
	RGBForeColor(&c[3]);
	dest_rect = title_rect;
	OffsetRect(&dest_rect,1,1);
	char_port_draw_string(talk_gworld,dest_rect,store_store_name,2,18);
	OffsetRect(&dest_rect,-1,-1);
	RGBForeColor(&c[4]);
	char_port_draw_string( talk_gworld,dest_rect,store_store_name,2,18);	

	TextFont(geneva_font_num);
	TextSize(12);
	TextFace(bold);

	RGBForeColor(&c[3]);
	switch (store_shop_type) {
		case 3: sprintf(cur_name,"Healing for %s.",univ.party[current_pc].name.c_str()); break;
		case 10: sprintf(cur_name,"Mage Spells for %s.",univ.party[current_pc].name.c_str());break;
		case 11: sprintf(cur_name,"Priest Spells for %s.",univ.party[current_pc].name.c_str()); break;
		case 12: sprintf(cur_name,"Buying Alchemy.");break;
		case 4: sprintf(cur_name,"Buying Food.");break;
		default:sprintf(cur_name,"Shopping for %s.",univ.party[current_pc].name.c_str()); break;
		}
	char_port_draw_string( talk_gworld,shopper_name,cur_name,2,18);	

	// Place help and done buttons
	ForeColor(blackColor);
	GetPortBounds(dlg_buttons_gworld[3][0],&help_from);
	talk_help_rect.right = talk_help_rect.left + help_from.right - help_from.left;
	talk_help_rect.bottom = talk_help_rect.top + help_from.bottom - help_from.top;
	rect_draw_some_item(dlg_buttons_gworld[3][pressed],help_from,talk_gworld,talk_help_rect);
	GetPortBounds(dlg_buttons_gworld[11][0],&help_from);
	//talk_help_rect.right = talk_help_rect.left + help_from.right - help_from.left;
	//talk_help_rect.bottom = talk_help_rect.top + help_from.bottom - help_from.top;
	rect_draw_some_item(dlg_buttons_gworld[11][pressed],help_from,talk_gworld,shop_done_rect);
	
	if (pressed)
		RGBForeColor(&c[4]);
	else ForeColor(blackColor);
		
	// Place all the items
	for (i = 0; i < 8; i++) {
		current_pos = i + GetControlValue(shop_sbar);
		if (store_shop_items[current_pos] < 0)
			break; // theoretically, this shouldn't happen
		cur_cost = store_shop_costs[current_pos];
		what_chosen = store_shop_items[current_pos];
		switch (what_chosen / 100) {
			case 0: case 1: case 2: case 3: case 4: 
				base_item = get_stored_item(what_chosen);
				base_item.ident = true;
				draw_dialog_graphic( talk_gworld, shopping_rects[i][2],base_item.graphic_num,PICT_ITEM, false,1);
				strcpy(cur_name,base_item.full_name.c_str());
				get_item_interesting_string(base_item,cur_info_str);
				break;
			case 5:
				base_item = store_alchemy(what_chosen - 500);
				draw_dialog_graphic( talk_gworld, shopping_rects[i][2],53,PICT_ITEM, false,1);//// all graphic nums
				strcpy(cur_name,base_item.full_name.c_str());
				strcpy(cur_info_str,"");
				break;
			case 6:
				//base_item = food_types[what_chosen - 600];
				//draw_dialog_graphic( talk_gworld, shopping_rects[i][2],633, false,1);
				//strcpy(cur_name,base_item.full_name);
				//get_item_interesting_string(base_item,cur_info_str);
				break;
			case 7:
				what_chosen -= 700;
				draw_dialog_graphic( talk_gworld, shopping_rects[i][2],99,PICT_ITEM, false,1);
				strcpy(cur_name,heal_types[what_chosen]);
				strcpy(cur_info_str,"");
				break;
			case 8:
				base_item = store_mage_spells(what_chosen - 800 - 30);
				draw_dialog_graphic( talk_gworld, shopping_rects[i][2],base_item.graphic_num,PICT_ITEM, false,1);

				strcpy(cur_name,base_item.full_name.c_str());
				strcpy(cur_info_str,"");		
				break;
			case 9:
				base_item = store_priest_spells(what_chosen - 900 - 30);
				draw_dialog_graphic( talk_gworld, shopping_rects[i][2],base_item.graphic_num,PICT_ITEM, false,1);
				strcpy(cur_name,base_item.full_name.c_str());
				strcpy(cur_info_str,"");
				break;
			default:
				what_magic_shop = (what_chosen / 1000) - 1;
				what_magic_shop_item = what_chosen % 1000;
				base_item = univ.party.magic_store_items[what_magic_shop][what_magic_shop_item];
				base_item.ident = true;
				draw_dialog_graphic( talk_gworld, shopping_rects[i][2],base_item.graphic_num,PICT_ITEM, false,1);
				strcpy(cur_name,base_item.full_name.c_str());
				get_item_interesting_string(base_item,cur_info_str);
				break;
			}

		// Now draw item shopping_rects[i][7]
		// 0 - whole area, 1 - active area 2 - graphic 3 - item name
		// 4 - item cost 5 - item extra str  6 - item help button
		TextSize(12);
		char_port_draw_string( talk_gworld,shopping_rects[i][3],cur_name,0,12);
		sprintf(cur_name,"Cost: %d",cur_cost);
		char_port_draw_string( talk_gworld,shopping_rects[i][4],cur_name,0,12);
		TextSize(10);
		char_port_draw_string( talk_gworld,shopping_rects[i][5],cur_info_str,0,12);
		if ((store_shop_type != 3) && (store_shop_type != 4))
			rect_draw_some_item(invenbtn_gworld,item_info_from,talk_gworld,shopping_rects[i][6],pressed ? srcCopy : transparent);

		}

	// Finally, cost info and help strs
	TextSize(12);
	sprintf(cur_name,"Prices here are %s.",cost_strs[store_cost_mult]);
	TextSize(10);
	char_port_draw_string( talk_gworld,bottom_help_rects[0],cur_name,0,12);
	char_port_draw_string( talk_gworld,bottom_help_rects[1],"Click on item name (or type 'a'-'h') to buy.",0,12);
	char_port_draw_string( talk_gworld,bottom_help_rects[2],"Hit done button (or Esc.) to quit.",0,12);
	if ((store_shop_type != 3) && (store_shop_type != 4))
		char_port_draw_string( talk_gworld,bottom_help_rects[3],"'I' button brings up description.",0,12);
	
	
	ForeColor(blackColor);
	GetPortBounds(talk_gworld,&area_rect);
	ClipRect(&area_rect);
	SetPort(old_port);

	refresh_shopping();
	ShowControl(shop_sbar);
	Draw1Control(shop_sbar);
}
Ejemplo n.º 11
0
void place_talk_str(char *str_to_place,char *str_to_place2,short color,Rect c_rect)
// color 0 - regular  1 - darker
{
	Rect area_rect;
	
	Rect face_rect = {6,6,38,38};
	Rect title_rect = {19,48,42,260};
	Rect dest_rect,help_from = {85,36,101,54};
	Str255 fn2 = "\pDungeon Bold";
	Str255 fn3 = "\pPalatino";

	short i,j,str_len,line_height = 17;
	Str255 p_str,str,str_to_draw,str_to_draw2;
	short text_len[257],current_rect,store_last_word_break = 0,start_of_last_kept_word = -1;
	short last_line_break = 0,last_word_break = 0,on_what_line = 0,last_stored_word_break = 0;
	bool force_skip = false;
	short face_to_draw;
	
	RGBColor c[7] = {{0,0,0},{0,0,32767},{0,0,14535},{0,0,26623},{0,0,59391},
	{0,40959,0},{0,24575,0}};
	
	GrafPtr old_port;
	
	GetPort(&old_port);
	SetPort( talk_gworld);

	// This redundancy is to try to keep the font from disappearing
	GetFNum(fn2,&dungeon_font_num);
	if (dungeon_font_num == 0)
		GetFNum(fn3,&dungeon_font_num);
		
	TextFont(dungeon_font_num);
	//TextFont(geneva_font_num);
	TextSize(18);
	TextFace(0);

	if (c_rect.right > 0) {
		ClipRect(&c_rect);	
		}

	GetPortBounds(talk_gworld,&area_rect);
	FrameRect(&area_rect);
	InsetRect(&area_rect,1,1);
	tileImage(area_rect,bg_gworld,bg[12]);

	// Put help button
	GetPortBounds(dlg_buttons_gworld[3][0], &help_from);
	talk_help_rect.right = talk_help_rect.left + help_from.right - help_from.left;
	talk_help_rect.bottom = talk_help_rect.top + help_from.bottom - help_from.top;
	rect_draw_some_item(dlg_buttons_gworld[3][0],help_from,talk_gworld,talk_help_rect);
	
	// Place face of talkee
	if ((color == 0) && (c_rect.right == 0)) { 
		////
		SetPort(GetWindowPort(mainPtr));
		face_to_draw = scenario.scen_monsters[store_monst_type].default_facial_pic;
		if (store_talk_face_pic >= 0)
			face_to_draw = store_talk_face_pic;
		if (store_talk_face_pic >= 1000) {
			draw_dialog_graphic(  talk_gworld, face_rect, store_talk_face_pic, PICT_CUSTOM + PICT_TALK, false,1);
			}
			else {
				i = get_monst_picnum(store_monst_type);
				if (face_to_draw <= 0)
					draw_dialog_graphic(talk_gworld, face_rect, i, get_monst_pictype(store_monst_type), false,1);
				else draw_dialog_graphic(talk_gworld, face_rect, face_to_draw, PICT_MONST, false,1);
			}
		SetPort( talk_gworld);
		}
	// Place name oftalkee
	RGBForeColor(&c[3]);
	dest_rect = title_rect;
	OffsetRect(&dest_rect,1,1);
	char_port_draw_string( talk_gworld,dest_rect,title_string,2,18);
	OffsetRect(&dest_rect,-1,-1);
	RGBForeColor(&c[4]);
	char_port_draw_string( talk_gworld,dest_rect,title_string,2,18);
		
	// Place buttons at bottom.
	if (color == 0)
		RGBForeColor(&c[5]);
		else RGBForeColor(&c[6]);
	for (i = 0; i < 9; i++) 
		if ((talk_end_forced == false) || (i == 6) || (i == 5)) {
			OffsetRect(&preset_words[i].word_rect,0,8);
			char_port_draw_string( talk_gworld,preset_words[i].word_rect,preset_words[i].word,2,18);
			OffsetRect(&preset_words[i].word_rect,0,-8);
			}
	// Place bulk of what said. Save words.
	//TextSize(14);
	if (color == 0)
		for (i = 0; i < 50; i++)
			store_words[i].word_rect.left = store_words[i].word_rect.right = 0;
			
	str_len = (short) strlen((char *)str_to_place);
	if (str_len == 0) {
		sprintf((char *) str_to_place,".");
		}	
	strcpy((char *) str,str_to_place);
	strcpy((char *) p_str,str_to_place);
	c2pstr((char*)p_str);	
	for (i = 0; i < 257; i++)
		text_len[i]= 0;
	MeasureText(256,p_str,text_len);

	dest_rect = word_place_rect;

	current_rect = 0;
	
	if (color == 0)
		RGBForeColor(&c[2]);
		else RGBForeColor(&c[1]);
	MoveTo(dest_rect.left + 1 , dest_rect.top + 1 + line_height * on_what_line + 9);
	//for (i = 0;text_len[i] != text_len[i + 1], i < str_len;i++) {
	for (i = 0;i < str_len;i++) {
		if (((str[i] != 39) && ((str[i] < 65) || (str[i] > 122)) && ((str[i] < 48) || (str[i] > 57))) && (color == 0)) { // New word, so set up a rect
			if (((i - store_last_word_break >= 4) || (i >= str_len - 1)) 
			 && (i - last_stored_word_break >= 4) && (talk_end_forced == false)) {
				store_words[current_rect].word_rect.left = dest_rect.left + (text_len[store_last_word_break] - text_len[last_line_break]) - 2;
				store_words[current_rect].word_rect.right = dest_rect.left + (text_len[i + 1] - text_len[last_line_break]) - 1;
				store_words[current_rect].word_rect.top = dest_rect.top + 1 + line_height * on_what_line - 5;
				store_words[current_rect].word_rect.bottom = dest_rect.top + 1 + line_height * on_what_line + 13;
				
				if ((str[store_last_word_break] < 48) || (str[store_last_word_break] == 96) 
					|| (str[store_last_word_break] > 122)
					|| ((str[store_last_word_break] >= 58) && (str[store_last_word_break] <= 64)))
						store_last_word_break++;

				// adjust for if this word will be scrolled down
				//if (((text_len[i] - text_len[last_line_break] > (dest_rect.right - dest_rect.left - 6)) 
		  		//	&& (last_word_break > last_line_break)) || (str[i] == '|')) {
		  		//	OffsetRect(&store_words[current_rect].word_rect,5 + -1 * store_words[current_rect].word_rect.left,line_height);
		  		//	}
				
				store_words[current_rect].word[0] = str[store_last_word_break];
				store_words[current_rect].word[1] = str[store_last_word_break + 1];
				store_words[current_rect].word[2] = str[store_last_word_break + 2];
				store_words[current_rect].word[3] = str[store_last_word_break + 3];
				store_words[current_rect].word[4] = 0;
				for (j = 0; j < 4; j++)
					if ((store_words[current_rect].word[j] >= 65) && (store_words[current_rect].word[j] <= 90))
						store_words[current_rect].word[j] += 32;
				if (scan_for_response(store_words[current_rect].word) < 0) {
					store_words[current_rect].word_rect.left = store_words[current_rect].word_rect.right = 0;
					}
					else {
						start_of_last_kept_word = store_last_word_break;
						if (current_rect < 49)
							current_rect++;
					
						//FrameRect(&store_words[current_rect].word_rect);
						}
				last_stored_word_break = i + 1;
				}
			}
		if (((text_len[i] - text_len[last_line_break] > (dest_rect.right - dest_rect.left - 6)) 
		  && (last_word_break > last_line_break)) || (str[i] == '|') || (i == str_len - 1)) {
			if (str[i] == '|') {
				str[i] = ' ';
		 		force_skip = true;
	 			}
	 		store_last_word_break = last_word_break;
	 		if (i == str_len - 1)
	 			last_word_break = i + 2;
			sprintf((char *)str_to_draw,"                                                         ");
			strncpy ((char *) str_to_draw,(char *) str + last_line_break,(size_t) (last_word_break - last_line_break - 1));
			sprintf((char *)str_to_draw2," %s",str_to_draw);
			str_to_draw2[0] = (char) strlen((char *)str_to_draw);
			DrawString(str_to_draw2);
			on_what_line++;
			MoveTo(dest_rect.left + 1 , dest_rect.top + 1 + line_height * on_what_line + 9);
			last_line_break = last_word_break;
			if (force_skip == true) {
				force_skip = false;
				i++;
				last_line_break++;
				last_word_break++;
				}
			if ((start_of_last_kept_word >= last_line_break) && (current_rect > 0)) {
				//SysBeep(2);
	 			OffsetRect(&store_words[current_rect - 1].word_rect,5 + -1 * store_words[current_rect - 1].word_rect.left,line_height);				
				}
		}
		if (str[i] == ' ') { // New word
			store_last_word_break = last_word_break = i + 1;
			}
		if (on_what_line == 17)
			i = 10000;
		}
		
	// Now for string 2
	str_len = (short) strlen((char *)str_to_place2);
	start_of_last_kept_word = -1;
	
	if (str_len > 0) {
		
	strcpy((char *) str,str_to_place2);
	strcpy((char *) p_str,str_to_place2);
	c2pstr((char*)p_str);	
	for (i = 0; i < 257; i++)
		text_len[i]= 0;
	MeasureText(256,p_str,text_len);
	
	last_line_break = store_last_word_break = last_word_break = last_stored_word_break = 0;
	MoveTo(dest_rect.left + 1 , dest_rect.top + 1 + line_height * on_what_line + 9);
	//for (i = 0;text_len[i] != text_len[i + 1], i < str_len;i++) 
	for (i = 0;i < str_len;i++) {
		if (((str[i] != 39) && ((str[i] < 65) || (str[i] > 122)) && ((str[i] < 48) || (str[i] > 57))) && (color == 0))  { // New word, so set up a rect
			if (((i - store_last_word_break >= 4) || (i >= str_len - 1)) 
			 && (i - last_stored_word_break >= 4) && (talk_end_forced == false)) {
				store_words[current_rect].word_rect.left = dest_rect.left + (text_len[store_last_word_break] - text_len[last_line_break]) - 2;
				store_words[current_rect].word_rect.right = dest_rect.left + (text_len[i + 1] - text_len[last_line_break]) - 1;
				store_words[current_rect].word_rect.top = dest_rect.top + 1 + line_height * on_what_line - 5;
				store_words[current_rect].word_rect.bottom = dest_rect.top + 1 + line_height * on_what_line + 13;
				
				if ((str[store_last_word_break] < 48) || (str[store_last_word_break] == 96) 
					|| (str[store_last_word_break] > 122)
					|| ((str[store_last_word_break] >= 58) && (str[store_last_word_break] <= 64)))
						store_last_word_break++;

				// adjust for if this word will be scrolled down
				//if (((text_len[i] - text_len[last_line_break] > (dest_rect.right - dest_rect.left - 6)) 
		  		//	&& (last_word_break > last_line_break)) || (str[i] == '|')) {
		  		//	OffsetRect(&store_words[current_rect].word_rect,5 + -1 * store_words[current_rect].word_rect.left,line_height);
		  		//	}
				store_words[current_rect].word[0] = str[store_last_word_break];
				store_words[current_rect].word[1] = str[store_last_word_break + 1];
				store_words[current_rect].word[2] = str[store_last_word_break + 2];
				store_words[current_rect].word[3] = str[store_last_word_break + 3];
				store_words[current_rect].word[4] = 0;
				for (j = 0; j < 4; j++)
					if ((store_words[current_rect].word[j] >= 65) && (store_words[current_rect].word[j] <= 90))
						store_words[current_rect].word[j] += 32;
				if (scan_for_response(store_words[current_rect].word) < 0)
					store_words[current_rect].word_rect.left = store_words[current_rect].word_rect.right = 0;
					else {
						start_of_last_kept_word = store_last_word_break;
						if (current_rect < 49)
							current_rect++;
					
						//FrameRect(&store_words[current_rect].word_rect);
						}
				last_stored_word_break = i + 1;
				}
			}
		if (((text_len[i] - text_len[last_line_break] > (dest_rect.right - dest_rect.left - 6)) 
		  && (last_word_break > last_line_break)) || (str[i] == '|') || (i == str_len - 1)) {
			if (str[i] == '|') {
				str[i] = ' ';
		 		force_skip = true;
	 			}
	 		store_last_word_break = last_word_break;
	 		if (i == str_len - 1)
	 			last_word_break = i + 2;
			sprintf((char *)str_to_draw,"                                                         ");
			strncpy ((char *) str_to_draw,(char *) str + last_line_break,(size_t) (last_word_break - last_line_break - 1));
			sprintf((char *)str_to_draw2," %s",str_to_draw);
			str_to_draw2[0] = (char) strlen((char *)str_to_draw);
			DrawString(str_to_draw2);
			on_what_line++;
			MoveTo(dest_rect.left + 1 , dest_rect.top + 1 + line_height * on_what_line + 9);
			last_line_break = last_word_break;
			if (force_skip == true) {
				force_skip = false;
				i++;
				last_line_break++;
				last_word_break++;
				}
			if ((start_of_last_kept_word >= last_line_break) && (current_rect > 0)) {
	 			OffsetRect(&store_words[current_rect - 1].word_rect,5 + -1 * store_words[current_rect - 1].word_rect.left,line_height);				
				}
		}
		if (str[i] == ' ') { // New word
			store_last_word_break = last_word_break = i + 1;
			}
		if (on_what_line == 17)
			i = 10000;
		}
	}
	
	ForeColor(blackColor);
	GetPortBounds(talk_gworld,&area_rect);
	Rect oldRect = area_rect;
	ClipRect(&area_rect);
	
	// Finally place processed graphics
	SetPort(GetWindowPort(mainPtr));
	rect_draw_some_item(talk_gworld,oldRect,talk_area_rect,ul);
	SetPort(old_port);
	
	// Clean up strings
	for (i = 0; i < 50; i++)
		for (j = 0; j < 4; j++)
			if ((store_words[current_rect].word[j] >= 65) && (store_words[current_rect].word[j] <= 90))
				store_words[current_rect].word[j] += 32;

}
Ejemplo n.º 12
0
void display_party(short mode,short clear_first)
//short mode; // 0 - 5 this pc, 6 - all
//short clear_first; // 1 - redraw over what's already there, 0 - don't redraw over
{
	short i,k,string_num, cur_rect=0;
	Str255 to_draw, skill_value;	
	Rect from_base = {0,0,36,28},from_rect,no_party_rect,temp_rect;
	
	// lots of stuff is global. Like ...
	// bool file_in_mem
	// short current_active_pc
	if (clear_first == 1) { // first erase what's already there
		for (i = 0; i < 6; i++)
			tileImage(pc_area_buttons[i][0],bg_gworld,bg[12]);
		tileImage(name_rect,bg_gworld,bg[12]);
		tileImage(pc_race_rect,bg_gworld,bg[12]);
		tileImage(info_area_rect,bg_gworld,bg[12]);
		frame_dlog_rect(GetWindowPort(mainPtr),pc_info_rect,1); // re-draw the frame
	}
	
	if (file_in_mem == false) { // what if no party loaded?
		no_party_rect=pc_info_rect;
		no_party_rect.top+=5;
		no_party_rect.left+=5;
		char_win_draw_string(mainPtr,no_party_rect,"No party loaded.",0,10);
	}
	else {
		from_rect = pc_info_rect;
		from_rect.top = from_rect.bottom - 14;
		if (party_in_scen == false)
			char_win_draw_string(mainPtr,from_rect,"Party not in a scenario.",0,10);
		else
			char_win_draw_string(mainPtr,from_rect,"Party is in a scenario.",0,10);
		for (i = 0; i < 6; i++) {
			if (i == current_active_pc) // active pc is drawn in blue
				ForeColor(blueColor);
			else ForeColor(blackColor);
			
			from_rect = (current_pressed_button == i) ? ed_buttons_from[1] : ed_buttons_from[0];
			
			if ((current_pressed_button < 0) || (current_pressed_button == i))
				rect_draw_some_item(buttons_gworld,from_rect,pc_area_buttons[i][0],(Point){0,0});
			ForeColor(blackColor);
			
			// pc_record_type is the records that contains chaarcters
			// main_status determins 0 - not exist, 1 - alive, OK, 2 - dead, 3 - stoned, 4 - dust
			if (univ.party[i].main_status != 0) { // PC exists?
				from_rect = from_base;
				// draw PC graphic
				OffsetRect(&from_rect,56 * (univ.party[i].which_graphic / 8),36 * (univ.party[i].which_graphic % 8));
				rect_draw_some_item(pc_gworld,from_rect,pc_area_buttons[i][1],(Point){0,0},transparent);
				
				//frame_dlog_rect(GetWindowPort(mainPtr),pc_area_buttons[i][1],0); 
				// draw name
				TextSize(9);
				if( (univ.party[i].name.length()) >= 10) {
					TextFace(0);
					sprintf((char *) to_draw, "%-s  ", (char *) univ.party[i].name.c_str());	
					TextSize(6);
				}
				else {
					sprintf((char *) to_draw, "%-s ", (char *) univ.party[i].name.c_str());	
				}
				
				ForeColor(whiteColor);
				win_draw_string(GetWindowPort(mainPtr),pc_area_buttons[i][2],to_draw,1,10);
				TextFace(bold);
				TextSize(10);
				
				if (i == current_active_pc){
					sprintf((char *) to_draw, "%-.18s  ", (char *) univ.party[i].name.c_str());
					if( (univ.party[i].name.length()) > 12)
						TextSize(8);
					ForeColor(blackColor);
					win_draw_string(GetWindowPort(mainPtr),name_rect,to_draw,1,10);
					TextSize(10);
				}
				if ((current_pressed_button < 0) || (current_pressed_button == i))
					switch (univ.party[i].main_status) {
							// draw statistics
						case 1:
							if (i == current_active_pc) {
								//Draw in race
								if (univ.party[i].race == 0)
									char_win_draw_string(mainPtr,pc_race_rect,"Human   ",1,10);
								if (univ.party[i].race == 1)
									char_win_draw_string(mainPtr,pc_race_rect,"Nephilim   ",1,10);
								if (univ.party[i].race == 2)
									char_win_draw_string(mainPtr,pc_race_rect,"Slithzerikai  ",1,10);
								// Draw in skills	
								
								sprintf((char *) to_draw, "Skills:");
								win_draw_string(GetWindowPort(mainPtr),skill_rect,to_draw,0,10);
								sprintf((char *) to_draw, "Hp: %d/%d  Sp: %d/%d",univ.party[i].cur_health,univ.party[i].max_health,univ.party[i].cur_sp,
										univ.party[i].max_sp);
								win_draw_string(GetWindowPort(mainPtr),hp_sp_rect,to_draw,0,10);
								
								
								TextSize(9);
								TextFace(0);
								string_num=1;
								for( k = 0; k < 19 ; ++k)
								{
									temp_rect = pc_skills_rect[k];
									temp_rect.left = pc_skills_rect[k].left + 80;
									
									get_str(to_draw,9,string_num);
									win_draw_string(GetWindowPort(mainPtr),pc_skills_rect[k],to_draw,0,9);
									
									sprintf((char *) skill_value,"%d",univ.party[i].skills[k]);
									win_draw_string(GetWindowPort(mainPtr),temp_rect,skill_value,0,9);	
									//frame_dlog_rect(GetWindowPort(mainPtr),pc_skills_rect[k],0);
									string_num+=2;
								}
								//end skills
								
								//Write in pc Status
								TextSize(10);
								TextFace(bold);	
								sprintf((char *) to_draw, "Status:");
								win_draw_string(GetWindowPort(mainPtr),status_rect,to_draw,0,10);
								
								TextSize(9);
								TextFace(0);
								//for(k = 0 ; k < 10; k++)
								//frame_dlog_rect(GetWindowPort(mainPtr),pc_status_rect[k],0);
								if (univ.party[i].status[0] > 0) 
									if(cur_rect <= 9) {
										char_win_draw_string(mainPtr,pc_status_rect[cur_rect],"Poisoned Weap.",0,9);
										cur_rect++;
									}
								if (univ.party[i].status[1] > 0) 
									if(cur_rect <= 9) {
										char_win_draw_string(mainPtr,pc_status_rect[cur_rect],"Blessed",0,9);
										cur_rect++;
									}
									else if(univ.party[i].status[1] < 0)
										if(cur_rect <= 9) {
											char_win_draw_string(mainPtr,pc_status_rect[cur_rect],"Cursed",0,9);
											cur_rect++;
										}
								if (univ.party[i].status[2] > 0) 
									if(cur_rect <= 9) {
										char_win_draw_string(mainPtr,pc_status_rect[cur_rect],"Poisoned",0,9);
										cur_rect++;
									}	
								if (univ.party[i].status[3] > 0) 
									if(cur_rect <= 9) {
										char_win_draw_string(mainPtr,pc_status_rect[cur_rect],"Hasted",0,9);
										cur_rect++;
									}
									else if(univ.party[i].status[3] < 0)
										if(cur_rect <= 9) {
											char_win_draw_string(mainPtr,pc_status_rect[cur_rect],"Slowed",0,9);
											cur_rect++;
										}
								if (univ.party[i].status[4] > 0) 
									if(cur_rect <= 9) {
										char_win_draw_string(mainPtr,pc_status_rect[cur_rect],"Invulnerable",0,9);
										cur_rect++;
									}
								if (univ.party[i].status[5] > 0) 
									if(cur_rect <= 9) {
										char_win_draw_string(mainPtr,pc_status_rect[cur_rect],"Magic Resistant",0,9);
										cur_rect++;
									}
								if (univ.party[i].status[6] > 0) 
									if(cur_rect <= 9) {
										char_win_draw_string(mainPtr,pc_status_rect[cur_rect],"Webbed",0,9);
										cur_rect++;
									}
								if (univ.party[i].status[7] > 0) 
									if(cur_rect <= 9) {
										char_win_draw_string(mainPtr,pc_status_rect[cur_rect],"Diseased",0,9);
										cur_rect++;
									}
								if (univ.party[i].status[8] > 0) 
									if(cur_rect <= 9) {
										char_win_draw_string(mainPtr,pc_status_rect[cur_rect],"Sanctury",0,9);
										cur_rect++;
									}
								if (univ.party[i].status[9] > 0) 
									if(cur_rect <= 9) {
										char_win_draw_string(mainPtr,pc_status_rect[cur_rect],"Dumbfounded",0,9);
										cur_rect++;
									}
								if (univ.party[i].status[10] > 0) 
									if(cur_rect <= 9) {
										char_win_draw_string(mainPtr,pc_status_rect[cur_rect],"Martyr's Shield",0,9);
										cur_rect++;
									}
								if (univ.party[i].status[11] > 0) 
									if(cur_rect <= 9) {
										char_win_draw_string(mainPtr,pc_status_rect[cur_rect],"Asleep",0,9);
										cur_rect++;
									}
								if (univ.party[i].status[12] > 0) 
									if(cur_rect <= 9) {
										char_win_draw_string(mainPtr,pc_status_rect[cur_rect],"Paralyzed",0,9);
										cur_rect++;
									}
								if (univ.party[i].status[13] > 0) 
									if(cur_rect <= 9) {
										char_win_draw_string(mainPtr,pc_status_rect[cur_rect],"Acid",0,9);
										cur_rect++;
									}
								//end pc status section
								
								//Write in Traits
								TextSize(10);
								TextFace(bold);	
								sprintf((char *) to_draw, "Traits:");
								win_draw_string(GetWindowPort(mainPtr),traits_rect,to_draw,0,10);
								//for(k = 0 ; k < 16; k++)
								//frame_dlog_rect(GetWindowPort(mainPtr),pc_traits_rect[k],0);
								TextSize(9);
								TextFace(0);	
								cur_rect=0;
								if (univ.party[i].traits[0] == 1) 
									if(cur_rect <= 15) {
										char_win_draw_string(mainPtr,pc_traits_rect[cur_rect],"Toughness",0,9);
										cur_rect++;
									}
								if (univ.party[i].traits[1] == 1) 
									if(cur_rect <= 15) {
										char_win_draw_string(mainPtr,pc_traits_rect[cur_rect],"Magically Apt",0,9);
										cur_rect++;
									}		
								if (univ.party[i].traits[2] == 1) 
									if(cur_rect <= 15) {
										char_win_draw_string(mainPtr,pc_traits_rect[cur_rect],"Ambidextrous",0,9);
										cur_rect++;
									}
								if (univ.party[i].traits[3] == 1) 
									if(cur_rect <= 15) {
										char_win_draw_string(mainPtr,pc_traits_rect[cur_rect],"Nimble Fingers",0,9);
										cur_rect++;
									}
								if (univ.party[i].traits[4] == 1) 
									if(cur_rect <= 15) {
										char_win_draw_string(mainPtr,pc_traits_rect[cur_rect],"Cave Lore",0,9);
										cur_rect++;
									}
								
								if (univ.party[i].traits[5] == 1) 
									if(cur_rect <= 15) {
										char_win_draw_string(mainPtr,pc_traits_rect[cur_rect],"Woodsman",0,9);
										cur_rect++;
									}
								if (univ.party[i].traits[6] == 1) 
									if(cur_rect <= 15) {
										char_win_draw_string(mainPtr,pc_traits_rect[cur_rect],"Good Constitution",0,9);
										cur_rect++;
									}		
								if (univ.party[i].traits[7] == 1) 
									if(cur_rect <= 15) {
										char_win_draw_string(mainPtr,pc_traits_rect[cur_rect],"Highly Alert",0,9);
										cur_rect++;
									}
								if (univ.party[i].traits[8] == 1) 
									if(cur_rect <= 15) {
										char_win_draw_string(mainPtr,pc_traits_rect[cur_rect],"Exceptional Str.",0,9);
										cur_rect++;
									}
								if (univ.party[i].traits[9] == 1) 
									if(cur_rect <= 15) {
										char_win_draw_string(mainPtr,pc_traits_rect[cur_rect],"Recuperation",0,9);
										cur_rect++;
									}
								if (univ.party[i].traits[10] == 1) 
									if(cur_rect <= 15) {
										char_win_draw_string(mainPtr,pc_traits_rect[cur_rect],"Sluggish",0,9);
										cur_rect++;
									}
								if (univ.party[i].traits[11] == 1) 
									if(cur_rect <= 15) {
										char_win_draw_string(mainPtr,pc_traits_rect[cur_rect],"Magically Inept",0,9);
										cur_rect++;
									}		
								if (univ.party[i].traits[12] == 1) 
									if(cur_rect <= 15) {
										char_win_draw_string(mainPtr,pc_traits_rect[cur_rect],"Frail",0,9);
										cur_rect++;
									}
								if (univ.party[i].traits[13] == 1) 
									if(cur_rect <= 15) {
										char_win_draw_string(mainPtr,pc_traits_rect[cur_rect],"Chronic Disease",0,9);
										cur_rect++;
									}
								if (univ.party[i].traits[14] == 1) 
									if(cur_rect <= 15) {
										char_win_draw_string(mainPtr,pc_traits_rect[cur_rect],"Bad Back",0,9);
										cur_rect++;
									}
								
								//end traits
							}
							
							ForeColor(whiteColor);
							TextSize(9);
							TextFace(0);
							char_win_draw_string(mainPtr,pc_area_buttons[i][3],"Alive ",1,10);
							TextFace(bold);
							TextSize(10);
							break;
							case 2:
							ForeColor(whiteColor);
							TextSize(9);
							TextFace(0);
							char_win_draw_string(mainPtr,pc_area_buttons[i][3],"Dead ",1,10);
							TextFace(bold);
							TextSize(10);
							break;
							case 3:
							ForeColor(whiteColor);
							TextSize(9);
							TextFace(0);
							char_win_draw_string(mainPtr,pc_area_buttons[i][3],"Dust ",1,10);
							TextFace(bold);
							TextSize(10);
							break;
							case 4:
							ForeColor(whiteColor);
							TextSize(9);
							TextFace(0);
							char_win_draw_string(mainPtr,pc_area_buttons[i][3],"Stone ",1,10);
							TextFace(bold);
							TextSize(10);
							break;
							case 5:
							ForeColor(whiteColor);
							TextSize(9);
							TextFace(0);
							char_win_draw_string(mainPtr,pc_area_buttons[i][3],"Fled ",1,10);
							TextFace(bold);
							TextSize(10);
							break;
							case 6:
							ForeColor(whiteColor);
							TextSize(9);
							TextFace(0); 
							char_win_draw_string(mainPtr,pc_area_buttons[i][3],"Surface ",1,10);
							TextFace(bold);
							TextSize(10);
							break;
							default:
							ForeColor(whiteColor);
							TextFace(0);
							TextSize(9);
							char_win_draw_string(mainPtr,pc_area_buttons[i][3],"Absent ",1,10);
							TextFace(bold);
							TextSize(10);
							break;
					}
				//frame_dlog_rect(GetWindowPort(mainPtr),pc_area_buttons[i][0],0); 
				
				
			}
			
		} // Closes the for i=6 loop
		ForeColor(blackColor);			
		
		for(i = 0; i < 5; i++) 
			if ((current_pressed_button < 0) || (current_pressed_button == i + 10)) {	
				if (clear_first == 1) { // first erase what's already there
					tileImage(edit_rect[i][0],bg_gworld,bg[12]);
				}		
				//frame_dlog_rect(GetWindowPort(mainPtr),edit_rect[i][0],0);
				//frame_dlog_rect(GetWindowPort(mainPtr),edit_rect[i][1],0);
				from_rect = (current_pressed_button == i + 10) ? ed_buttons_from[1] : ed_buttons_from[0];
				rect_draw_some_item(buttons_gworld,from_rect,edit_rect[i][0],(Point){0,0});
				ForeColor(whiteColor);			
				switch(i) {
					case 0:
						char_win_draw_string(mainPtr,edit_rect[0][1],"  Add  Mage Spells ",0,10);
						break;
					case 1:
						char_win_draw_string(mainPtr,edit_rect[1][1],"  Add Priest Spells ",0,10);
						break;
					case 2: 
						char_win_draw_string(mainPtr,edit_rect[2][1]," Edit  Traits",0,10);
						break;
					case 3:
						char_win_draw_string(mainPtr,edit_rect[3][1]," Edit  Skills",0,10);
						break;
					case 4:
						char_win_draw_string(mainPtr,edit_rect[4][1]," Edit   XP",0,10);
						break;
					default:
						break;	
				}		
				ForeColor(blackColor);			
				
			}
		//			MoveTo(start_h + 10, start_v + 127);	
		//			sprintf((char *) to_draw, " Gold: %d       Food: %d ",(short) party.gold, (short) party.food);
		//			DrawString(to_draw);
	}
	
	
	ForeColor(blackColor);
}
Ejemplo n.º 13
0
//extern Rect pc_area_buttons[6][6] ; // 0 - whole 1 - pic 2 - name 3 - stat strs 4,5 - later
//extern Rect item_string_rects[24][4]; // 0 - name 1 - drop  2 - id  3 - 
void draw_items(short clear_first)
//short clear_first; // 0 - redraw over, 1 - don't redraw over
{
	short i;
	Str255 to_draw;
	Rect d_from = {12,28,24,42},i_from = {12,42,24,56},dest_rect;

	if (file_in_mem == false)  // save file loaded
		return;

	dest_rect = item_string_rects[0][0];
	dest_rect.bottom += 3;
	OffsetRect(&dest_rect,0,-14);

	// First erase crap there already by painting background texture over it
	if (clear_first == 1) {
		for (i = 0; i < 24; i++)
			tileImage(item_string_rects[i][0],bg_gworld,bg[12]);	
		tileImage(dest_rect,bg_gworld,bg[12]);	
		}
	
	// First, draw "Fred's Items:"
	//sprintf((char *)to_draw,"%s items:",univ.party[current_active_pc].name);
	//TextSize(12);
	//ClipRect(&dest_rect);
	//win_draw_string(mainPtr,item_string_rects[0][0],to_draw,0,12);
	//undo_clip();
	//TextSize(10);

	if (univ.party[current_active_pc].main_status != 1){
		frame_dlog_rect(GetWindowPort(mainPtr),pc_info_rect,1); // re draw entire frame 
		frame_dlog_rect(GetWindowPort(mainPtr),info_area_rect,1); // draw the frame
		frame_dlog_rect(GetWindowPort(mainPtr),pc_race_rect,1); // draw the frame	
		return; // If PC is dead, it has no items
	}
	for (i = 0; i < 24; i++) // Loop through items and draw each
		if (univ.party[current_active_pc].items[i].variety > 0) { // i.e. does item exist
			strcpy((char *) to_draw, "");
			if (!univ.party[current_active_pc].items[i].ident)
				sprintf((char *) to_draw, "%d. %s  ",i + 1,univ.party[current_active_pc].items[i].name.c_str());
				else if (univ.party[current_active_pc].items[i].charges > 0)
					sprintf((char *) to_draw, "%d. %s (%d)",i + 1,univ.party[current_active_pc].items[i].full_name.c_str(),
					univ.party[current_active_pc].items[i].charges);
				else sprintf((char *) to_draw, "%d. %s ",i + 1,univ.party[current_active_pc].items[i].full_name.c_str());

			//if (i % 2 == 0)
			//	sprintf((char *) to_draw, "%d %d %d %d",
			//	pc_info_rect.left,pc_info_rect.right,pc_info_rect.top,pc_info_rect.bottom);
			//	else sprintf((char *) to_draw, "%d %d %d %d",
			//	name_rect.left,name_rect.right,name_rect.top,name_rect.bottom);

			char_win_draw_string(mainPtr,item_string_rects[i][0],(char *) to_draw,0,10);

			//Draw id/drop buttons
			rect_draw_some_item(invenbtn_gworld,d_from,item_string_rects[i][1],(Point){0,0},transparent);
			rect_draw_some_item(invenbtn_gworld,i_from,item_string_rects[i][2],(Point){0,0},transparent);
			}
	frame_dlog_rect(GetWindowPort(mainPtr),pc_info_rect,1); // re draw entire frame 
	frame_dlog_rect(GetWindowPort(mainPtr),name_rect,1); // draw the frame
	frame_dlog_rect(GetWindowPort(mainPtr),pc_race_rect,1); // draw the frame
	frame_dlog_rect(GetWindowPort(mainPtr),info_area_rect,1); // draw the frame

}
Ejemplo n.º 14
0
void draw_main_screen()
{
	Rect	source_rect, dest_rec,dest_rect;
	Rect reg_rect;

	SetPort(GetWindowPort(mainPtr));
	tileImage(whole_win_rect,bg_gworld,bg[12]); // fill whole window with background texture
	dest_rec = source_rect = title_from; // initializes, to draw title 
		 // title_from is a Rect constant
	OffsetRect(&dest_rec,20,0);
	
	rect_draw_some_item (title_gworld,source_rect,dest_rec,(Point){0,0},transparent);
		// The first title_gworld is the from, the gworld to draw from
		// and source_rect is the rectangle in that gworld to draw
		// The 1,1 at the end means ...
		// the 1st 1 means transparent, if the first 1 was a 0, not transparent
		// The second 1 means on the main window, not into another gworld
		// dest_rec is where it's drawn to
		// Finally, the second title_gworld. This would be the gworld you were drawing into if
		// you were drawing into a gworld. You aren't so this doesn't matter, so just put the earlier
		// gworld in as a place holder.
	
	dest_rect = dest_rec;
	dest_rect.top = dest_rect.bottom;
	dest_rect.bottom = dest_rect.top + 50;
		// initialize rectangle to draw text into
	TextSize(12);
	TextFace(bold + underline);
		// set the pen
	//char_win_draw_string(GetWindowPort(mainPtr),dest_rect,"Characters",0,10);
		// This draws a chunk of text on the screen
	TextSize(10); /// reset text size
	TextFace(0); // reset text pen
	TextFace(bold);
	
	frame_dlog_rect(GetWindowPort(mainPtr),pc_info_rect,1); // draw the frame
	//i = pc_info_rect.left-pc_info_rect.right;
	//sprintf((char *)temp_str,"Width of pc_info_rect %d ",
				//(short) i);
	//win_draw_string(mainPtr,pc_info_rect,temp_str,0,12);

	
	dest_rect = pc_area_buttons[5][0]; 
	dest_rect.right = whole_win_rect.right - 30; //What is this for? Commenting it out has no effect.
	dest_rect.left += 60;
	//Off0setRect(&dest_rect,0,45);
	OffsetRect(&dest_rect,0,21);
	if (file_in_mem == true)
		char_win_draw_string(mainPtr,dest_rect,"Click on character to edit it.",0,10);
	else
		char_win_draw_string(mainPtr,dest_rect,"Select Open from File menu.",0,10);
	if(file_in_mem == true && party_in_scen==true && scen_items_loaded==false){
		OffsetRect(&dest_rect,200,0);
		char_win_draw_string(mainPtr,dest_rect,"Warning: Scenario item data could not be loaded.",0,10);
		OffsetRect(&dest_rect,-200,0);
	}
	OffsetRect(&dest_rect,0,12);
	if (file_in_mem == true)
		char_win_draw_string(mainPtr,dest_rect,"Press 'I' button to identify item, and 'D' button to drop item.",0,10);
	TextSize(12);
	OffsetRect(&dest_rect,0,16);
	if (file_in_mem == true)
		char_win_draw_string(mainPtr,dest_rect,"Back up save file before editing it!",0,10);
	TextSize(10);
	TextFace(0);
	OffsetRect(&dest_rect,280,0);
	char_win_draw_string(mainPtr,dest_rect,"Created in 1997 by Spiderweb Software, Inc.",0,10);
	TextFace(bold);
	
	
	reg_rect = whole_win_rect;
	reg_rect.left = reg_rect.right - 170;
	reg_rect.top += 8;
	reg_rect.right -= 3;
	
}