コード例 #1
0
ファイル: JSONValue.cpp プロジェクト: AGreatFish/Urho3D
void JSONValue::AddVariantValue(const Variant& value)
{
    switch (value.GetType())
    {
    case VAR_RESOURCEREF:
        AddResourceRef(value.GetResourceRef());
        break;

    case VAR_RESOURCEREFLIST:
        AddResourceRefList(value.GetResourceRefList());
        break;

    case VAR_VARIANTVECTOR:
    case VAR_VARIANTMAP:
        LOGERROR("Unsupported value type");
        break;

    default:
        AddString(value.ToString());
    }
}
コード例 #2
0
ファイル: MACRODLG.CPP プロジェクト: jimmccurdy/ArchiveGit
void CSmartFieldListBox::Rebuild(void)
{
	int nMacros = m_pMacros->Macros();

	SetRedraw(FALSE);

	ResetContent();

/* Set the height of the items. */

	MEASUREITEMSTRUCT mi;

	MeasureItem(&mi);
	SetItemHeight(0, mi.itemHeight);

/* Add all the items. */

	for (int nMacro = 0; nMacro < nMacros; nMacro++)
	{
		CMacro* pMacro = m_pMacros->Macro(nMacro);

		ASSERT(pMacro != NULL);

		if (pMacro != NULL && ShowMacro(pMacro))
		{
			CSmartFieldListBoxItem* pItem = new CSmartFieldListBoxItem(pMacro, nMacro, m_pMacroServer);

			ASSERT(pItem != NULL);

			if (pItem != NULL)
			{
				AddString((LPCSTR)pItem);
			}
		}
	}
	SetRedraw(TRUE);

	// No state is saved yet.
	m_fSavedState = FALSE;
}
コード例 #3
0
ファイル: CargoHolder.cpp プロジェクト: vkholodkov/freestars
TiXmlNode * CargoHolder::WriteTransport(TiXmlNode * node) const
{
	const Planet * p = dynamic_cast<const Planet *>(this);
	if (p != NULL) {
		AddString(node, "Planet", p->GetName().c_str());
		return node;
	}

	const Fleet * f = dynamic_cast<const Fleet *>(this);
	if (f != NULL) {
		AddLong(node, "Fleet", GetID());
		AddLong(node, "Owner", GetOwner()->GetID());
		return node;
	}

//	const Packet * pac = dynamic_cast<const Packet *>(this);
//	if (pac != NULL) {
//		return node;
//	}

	return node;
}
コード例 #4
0
ファイル: sign.c プロジェクト: rockgarden/MyCard
// JNIEnv *env, jobject thiz 默认传入
// 被调用的方法要放在前面,否则报错:conflicting types for "方法名"
JNIEXPORT jstring JNICALL Java_com_rockgarden_sign_jni_JniSignHolder_getCustomInfoMD5(
        JNIEnv *env, jobject thiz, jobject ctx, jstring jInfo) {

    jstring pkg_name = Java_com_rockgarden_sign_jni_Jni_GetPackageName(env, thiz, ctx);
    char *c1 = Jstring2CStr(env, pkg_name);
    char *c2 = "com.eastcom.mobile112";
    int result = strcmp(c1, c2);

    if (result == 0) {
        char *str = "AD161C0F-D5B5-86F2-6DCF-7D9ADCBC1AC7";
        jstring js = (*env)->NewStringUTF(env, str);
        //(*env)->ReleaseStringUTFChars(env, js, str);
        jstring newjs = AddString(env, jInfo, js);
        return Java_com_rockgarden_sign_jni_JniSignHolder_getInfoMD5(env, thiz, newjs);
    }
    else {
        char *c = "";
        jstring js = (*env)->NewStringUTF(env, c);
        //(*env)->ReleaseStringUTFChars(env, js, c);
        return js;
    }
}
コード例 #5
0
int CInPlaceCombo::OnCreate(LPCREATESTRUCT lpCreateStruct) 
{
	if (CComboBox::OnCreate(lpCreateStruct) == -1)
	{
		return -1;
	}
	
	// Set the proper font
	CFont* pFont = GetParent()->GetFont();
	SetFont(pFont);
	
	SetFocus();

	ResetContent(); 
	for (POSITION Pos_ = m_DropDownList.GetHeadPosition(); Pos_ != NULL;)
	{
		//AfxMessageBox((LPCTSTR) (m_DropDownList.GetNext(Pos_)));
		AddString((LPCTSTR) (m_DropDownList.GetNext(Pos_)));
	}

	return 0;
}
コード例 #6
0
ファイル: OXImageListBox.cpp プロジェクト: Spritutu/AiPI-1
int COXImageListBox::AddImageList(CImageList* pImageList)
{
	if(m_imageList.GetImageCount()==0)
		return -1;

	ASSERT(pImageList!=NULL);
	if(pImageList==NULL)
		return -1;

	if(pImageList->GetImageCount()==0)
		return -1;

	IMAGEINFO imageInfo;
	VERIFY(pImageList->GetImageInfo(0,&imageInfo));
	CRect rect(imageInfo.rcImage);
	VERIFY(m_imageList.GetImageInfo(0,&imageInfo));
	if(rect.Width()!=imageInfo.rcImage.right-imageInfo.rcImage.left ||
		rect.Height()!=imageInfo.rcImage.bottom-imageInfo.rcImage.top)
	{
		return -1;
	}

	int nLastImage=GetCount();
	int nIndex=0;
	for(nIndex=0; nIndex<pImageList->GetImageCount(); nIndex++)
	{
		HICON hIcon=pImageList->ExtractIcon(nIndex);
		ASSERT(hIcon!=NULL);
		VERIFY(m_imageList.Add(hIcon)!=-1);
		VERIFY(::DestroyIcon(hIcon));
	}

	for(nIndex=nLastImage; nIndex<m_imageList.GetImageCount(); nIndex++)
	{
		VERIFY(AddString((LPCTSTR)(INT_PTR)nIndex)>=0);
	}

	return nLastImage;
}
コード例 #7
0
ファイル: ecgdv.cpp プロジェクト: vagnerr/ECGHolterMonitor
void TDrawListView::FormatData(const Tecg* ecg,  int unsigned index)
{
	// Large number for now :-)
  char buf1[80];
  char buf2[80];
  char buf3[80];
  char buf4[80];
  char buf5[80];

//  TColor color(line->QueryColor());
  wsprintf(buf1, "No. Of Points in ECG = (%d)",
			  ecg->length());
  wsprintf(buf2, "(x,y) Scales         = (%d,%d)",
			  ecg->get_x_scale(), ecg->get_y_scale());
  wsprintf(buf3, "R Hight threshold    = (%d)",
			  ecg->get_r_thresh());
  wsprintf(buf4, "R Change threshold   = (%d)",
			  ecg->get_r_change());
  wsprintf(buf5, "Y (min,max)          = (%d,%d)",
			  ecg->get_y_min(), ecg->get_y_max());
  wsprintf(buf5, "Y mean               = (%d)",
			  ecg->get_y_mean());

//  DeleteString(index);
  ClearList();
  AddString(ecg->ECG_Data_String1.c_str());
  AddString(ecg->ECG_Data_String2.c_str());
  AddString(ecg->ECG_Data_String3.c_str());
  AddString(buf1);
  AddString(buf2);
  AddString(buf3);
  AddString(buf4);
  AddString(buf5);

  SetSelIndex(index);
}
コード例 #8
0
ファイル: ftrctrls.cpp プロジェクト: kcrazy/winekit
/*++

Routine Name:

    CUICtrlFeatNUpOrderCombo::OnInit

Routine Description:

    This is responsible for initialising the control and is called when
    the WM_INITDIALOG message is recieved. This method populates the combo
    box with the appropriate option strings.

Arguments:

    hDlg - handle to the parent window

Return Value:

    HRESULT
    S_OK - On success
    E_*  - On error

--*/
HRESULT
CUICtrlFeatNUpOrderCombo::OnInit(
    __in CONST HWND hDlg
    )
{
    HRESULT hr = S_OK;

    //
    // Populate the combo box
    //
    if (SUCCEEDED(hr = AddString(hDlg, g_hInstance, IDS_GPD_LTORTTOB)) &&
        SUCCEEDED(hr = AddString(hDlg, g_hInstance, IDS_GPD_TTOBLTOR)) &&
        SUCCEEDED(hr = AddString(hDlg, g_hInstance, IDS_GPD_RTOLTTOB)) &&
        SUCCEEDED(hr = AddString(hDlg, g_hInstance, IDS_GPD_TTOBRTOL)) &&
        SUCCEEDED(hr = AddString(hDlg, g_hInstance, IDS_GPD_LTORBTOT)) &&
        SUCCEEDED(hr = AddString(hDlg, g_hInstance, IDS_GPD_BTOTLTOR)) &&
        SUCCEEDED(hr = AddString(hDlg, g_hInstance, IDS_GPD_RTOLBTOT)))
    {
        hr = AddString(hDlg, g_hInstance, IDS_GPD_BTOTRTOL);
    }

    ERR_ON_HR(hr);
    return hr;
}
コード例 #9
0
/**
 *组装push消息接收到的响应包
 */
int ComposePkg(tASecMsgHead &stHead, tASecPushMsgRsp &stRsp, uint8_t *pPkg, int& iPkgBufSize)
{
	//数据预处理.做个保护措施
	stHead.usMsgType = MSG_TYPE_PUSH_MSG_RSP;
	CK_STR(stRsp.aszErrMsg);

	char szPkgBuf[1024];
	char *pCur = szPkgBuf;

	bzero(szPkgBuf, sizeof(szPkgBuf));

	*pCur = 0x02;
	pCur++;

	tASecMsgHead* pHead = (tASecMsgHead*)pCur;
	pCur+=sizeof(tASecMsgHead);

	memcpy(pHead, &stHead, sizeof(stHead));

	AddDWord(&pCur, NULL, stRsp.ulRet);
	AddString(&pCur, NULL, stRsp.aszErrMsg, strlen(stRsp.aszErrMsg));

	*pCur = 0x03;
	pCur++;

	int iPkgLen = pCur-szPkgBuf;
	if (iPkgLen > iPkgBufSize)
	{
		return -2;
	}

	pHead->usLength = iPkgLen;
	Hton(pHead);

	memcpy(pPkg, szPkgBuf, iPkgLen);
	iPkgBufSize=iPkgLen;
	return 0;
}
コード例 #10
0
ファイル: UIBarButtonItem.cpp プロジェクト: netroby/WinObjC
void UIBarButtonItem::ConvertStaticMappings(NIBWriter *writer, XIBObject *obj)
{
    AddOutputMember(writer, "UIEnabled", new XIBObjectBool(true));
    if ( _systemItem != -1 ) {
        AddInt(writer, "UISystemItem", _systemItem);
        AddBool(writer, "UIIsSystemItem", true);
    }
    if ( _title ) AddString(writer, "UITitle", _title);
    if ( !_customView ) {
        if ( _style ) AddInt(writer, "UIStyle", _style);
        if ( _width != -1.0f ) {
            AddOutputMember(writer, "UIWidth", new XIBObjectFloat(_width));
        }
    }
    if ( _customView ) {
        AddOutputMember(writer, "UICustomView", _customView);
    }
    if ( _connections ) 
    {
        for ( int i = 0; i < _connections->count(); i ++ ) {
            XIBObject *curObj = _connections->objectAtIndex(i);

            if ( strcmp(curObj->_className, "segue") == 0 ) {
                UIStoryboardSegue *segue = (UIStoryboardSegue *) curObj;

                UIRuntimeEventConnection *newEvent = new UIRuntimeEventConnection();
                newEvent->_label = "perform:";
                newEvent->_source = this;
                newEvent->_destination = segue;
                writer->_connections->AddMember(NULL, newEvent);
                writer->AddOutputObject(newEvent);

                //AddOutputMember(writer, "UIOutlet", refObj);
            }
        }
    }
    ObjectConverterSwapper::ConvertStaticMappings(writer, obj);
}
コード例 #11
0
ファイル: guilistb.c プロジェクト: Azarien/open-watcom-v2
bool GUIListBoxAddTextList( a_list *list, int items, const void *data_handle, GUIPICKGETTEXT *getstring )
{
    int         item;
    lb_data     old_data;
    lb_data     new_data;
    gui_ctl_idx choice;

    choice = -1;
    old_data = (lb_data)list->data_handle;
    new_data = ResizeList( list, items, &choice );
    if( new_data == NULL ) {
        return( false );
    }
    for( item = 0; item < items; ++item ) {
        if( !AddString( new_data, getstring( data_handle, item ), choice + item ) ) {
            return( false );
        }
    }
    GUIMemFree( (void *)old_data );
    list->data_handle = (const void *)new_data;
    uiupdatelistbox( list );
    return( true );
}
コード例 #12
0
//
/// Add item into checklist box.
//
/// Adds string of item to the list box, returning its position in the list
/// (0 is the first position). Returns a negative value if an error occurs.
/// The list items are automatically sorted unless the style LBS_SORT
/// is not used for list box creation.
//
int
TCheckList::AddItem(TCheckListItem* item)
{
   if(item){
    if (GetStyle() & LBS_SORT){
      int i=0;
      while(i < (int)Items.Size()){
        if(*Items[i] > *item)
          break;
        i++;
      }
      if(i >= (int)Items.Size())
        i = -1;
      return InsertItem(item, i);
    }
    else{
      if(GetHandle() && AddString((LPTSTR)item) < 0)
        return -1;
      return Items.Add(item);
    }
  }
  return -1;
}
コード例 #13
0
void AuxGroupMember::BuildExtendedPacket(unsigned char *buffer, long &index)
{
	AddFlags(ExtendedFlags, sizeof(ExtendedFlags), buffer, index);

	if (ExtendedFlags[0] & 0x10)	//ExtendedFlags[1] & 0x01
	{
		AddString(buffer, Data->Name, index);
	}

	if (ExtendedFlags[0] & 0x20)	//ExtendedFlags[1] & 0x02
	{
		AddData(buffer, Data->GameID, index);
	}

	if (ExtendedFlags[0] & 0x40)	//ExtendedFlags[1] & 0x04
	{
		AddData(buffer, Data->Formation, index);
	}

	if (ExtendedFlags[0] & 0x80)	//ExtendedFlags[1] & 0x08
	{
		AddData(buffer, Data->Position, index);
	}
}
コード例 #14
0
void cPlugDetailOsdMenu::SetDetail()
{
  SetPluginMenu(meDetail, libvdrskinservice::mtText);
  Clear();
  ClearValues();
  
  SetText("Text to be displayed if skin doesn't know anything about this plugin");

  AddInt("menuitem", element);
  AddString("tabtext", "String value to be displayed if skin doesn't know anything about this plugin");

  //Loop Token Example
  for (int row = 0; row < 25; row++) {
      libvdrskinservice::cKeyValueList<cString> *loopValues = new libvdrskinservice::cKeyValueList<cString>();
      for (int col = 0; col < 10; col++) {
          cString key = cString::sprintf("loop1[col%d]", col);
          cString *value = new cString(cString::sprintf("row%d-col%d", row, col));
          loopValues->AddKeyValue(*key, value);
      }
      AddLoopValues("loop1", loopValues);
  }

  Display();
}
コード例 #15
0
ファイル: XNoticeProcess.cpp プロジェクト: F5000/spree
bool _XNoticeProcess::SetNoticeProfile( int nMsgType, LPTSTR pMsg, int nMinStartTime, int nMinInterval, int nPrintCount, BOOL bLargeFont )
{
	vector<sMsgInfo*>::iterator iter = m_vtInfo.begin();

	for(; iter != m_vtInfo.end(); ++iter )
	{
		// ID 가 등록되어있으면 리턴
		if( (*iter)->nMsgID == nMsgType )
			return false;
	}

	// 메세지 정보 생성
	sMsgInfo* pMsgInfo = new sMsgInfo;

	// 아이디와 시작시간, 반복시간을 저장한다
	// nPrintCount 가 -1 이 아닌 양수가 지정되어있으면 그 숫자 만큼만 출력, 0 이면 절대 출력 되지 않음
	pMsgInfo->SetInfo( nMsgType, nMinStartTime, nMinInterval, nPrintCount, bLargeFont );
	m_vtInfo.push_back( pMsgInfo );

	if(	!AddString( nMsgType, pMsg ))
		return false;

	return true;
}
コード例 #16
0
ファイル: ORDERLB.CPP プロジェクト: jimmccurdy/ArchiveGit
void COrderListBox::AddItems(CProductItems* pItems, int nIndent)
{
	int nCount = pItems->ItemCount();

	for (int nIndex = 0; nIndex < nCount; nIndex++)
	{
		CProductItem* pItem = pItems->Item(nIndex);

		if (pItem != NULL)
		{
			COrderListBoxItem* pListBoxItem = new COrderListBoxItem(pItem, nIndent);

			if (pListBoxItem != NULL)
			{
				pListBoxItem->Mark(pItem->TestFlag(PRODUCT_ITEM_Marked));
				pListBoxItem->Select(pItem->TestFlag(PRODUCT_ITEM_Selected));

				AddString((LPCSTR)pListBoxItem);

				AddItems(pItem->Items(), nIndent+1);
			}
		}
	}
}
コード例 #17
0
BOOL CKTypeComboBox::Initialize( )
{
	ResetContent();
	
	int	ktype, nIndex, nSel = CB_ERR;

	ktype	=	CKData::ktypeMin5;
	nIndex	=	AddString( AfxGetKTypeString(ktype) );
	SetItemData( nIndex, ktype );

	ktype	=	CKData::ktypeMin15;
	nIndex	=	AddString( AfxGetKTypeString(ktype) );
	SetItemData( nIndex, ktype );

	ktype	=	CKData::ktypeMin30;
	nIndex	=	AddString( AfxGetKTypeString(ktype) );
	SetItemData( nIndex, ktype );

	ktype	=	CKData::ktypeMin60;
	nIndex	=	AddString( AfxGetKTypeString(ktype) );
	SetItemData( nIndex, ktype );
	
	ktype	=	CKData::ktypeDay;
	nIndex	=	AddString( AfxGetKTypeString(ktype) );
	SetItemData( nIndex, ktype );
	nSel	=	nIndex;

	ktype	=	CKData::ktypeWeek;
	nIndex	=	AddString( AfxGetKTypeString(ktype) );
	SetItemData( nIndex, ktype );

	ktype	=	CKData::ktypeMonth;
	nIndex	=	AddString( AfxGetKTypeString(ktype) );
	SetItemData( nIndex, ktype );

	SetCurSel( nSel );
	return TRUE;
}
コード例 #18
0
ファイル: ftrctrls.cpp プロジェクト: kcrazy/winekit
/*++

Routine Name:

    CUICtrlFeatPgScaleCombo::OnInit

Routine Description:

    This is responsible for initialising the control and is called when
    the WM_INITDIALOG message is recieved. This method populates the combo
    box with the appropriate option strings.

Arguments:

    hDlg - handle to the parent window

Return Value:

    HRESULT
    S_OK - On success
    E_*  - On error

--*/
HRESULT
CUICtrlFeatPgScaleCombo::OnInit(
    __in CONST HWND hDlg
    )
{
    HRESULT hr = S_OK;

    //
    // Populate the combo box
    //
    if (SUCCEEDED(hr = AddString(hDlg, g_hInstance, IDS_GPD_NONE)) &&
        SUCCEEDED(hr = AddString(hDlg, g_hInstance, IDS_GPD_CUSTOM)) &&
        SUCCEEDED(hr = AddString(hDlg, g_hInstance, IDS_GPD_CUSTSQUARE)) &&
        SUCCEEDED(hr = AddString(hDlg, g_hInstance, IDS_GPD_FITBLEED)) &&
        SUCCEEDED(hr = AddString(hDlg, g_hInstance, IDS_GPD_FITCONTENT)) &&
        SUCCEEDED(hr = AddString(hDlg, g_hInstance, IDS_GPD_FITPAGE)))
    {
        hr = AddString(hDlg, g_hInstance, IDS_GPD_SCALEPAGETOPAGE);
    }

    ERR_ON_HR(hr);
    return hr;
}
コード例 #19
0
ファイル: ftrctrls.cpp プロジェクト: kcrazy/winekit
/*++

Routine Name:

    CUICtrlFeatNUpCombo::OnInit

Routine Description:

    This is responsible for initialising the control and is called when
    the WM_INITDIALOG message is recieved. This method populates the combo
    box with the appropriate option strings.

Arguments:

    hDlg - handle to the parent window

Return Value:

    HRESULT
    S_OK - On success
    E_*  - On error

--*/
HRESULT
CUICtrlFeatNUpCombo::OnInit(
    __in CONST HWND hDlg
    )
{
    HRESULT hr = S_OK;

    //
    // Populate the combo box
    //
    if (SUCCEEDED(hr = AddString(hDlg, g_hInstance, IDS_GPD_1PPS)) &&
        SUCCEEDED(hr = AddString(hDlg, g_hInstance, IDS_GPD_2PPS)) &&
        SUCCEEDED(hr = AddString(hDlg, g_hInstance, IDS_GPD_4PPS)) &&
        SUCCEEDED(hr = AddString(hDlg, g_hInstance, IDS_GPD_6PPS)) &&
        SUCCEEDED(hr = AddString(hDlg, g_hInstance, IDS_GPD_8PPS)) &&
        SUCCEEDED(hr = AddString(hDlg, g_hInstance, IDS_GPD_9PPS)))
    {
        hr = AddString(hDlg, g_hInstance, IDS_GPD_16PPS);
    }

    ERR_ON_HR(hr);
    return hr;
}
コード例 #20
0
ファイル: main.c プロジェクト: baducki/android_NDK
JNIEXPORT jstring Java_org_nhnnext_ndktest_MainActivity_getAddedStringFromNative( JNIEnv* env, jobject obj) {

	return (*env)->NewStringUTF(env, AddString());
}
コード例 #21
0
size_t atcprintf(char *buffer, size_t maxlen, const char *format, IPluginContext *pCtx, const cell_t *params, int *param)
{
	if (!buffer || !maxlen)
	{
		return 0;
	}

	int arg;
	int args = params[0];
	char *buf_p;
	char ch;
	int flags;
	int width;
	int prec;
	int n;
	char sign;
	const char *fmt;
	size_t llen = maxlen - 1;

	buf_p = buffer;
	arg = *param;
	fmt = format;

	while (true)
	{
		// run through the format string until we hit a '%' or '\0'
		for (ch = *fmt; llen && ((ch = *fmt) != '\0') && (ch != '%'); fmt++)
		{
			*buf_p++ = ch;
			llen--;
		}
		if ((ch == '\0') || (llen <= 0))
		{
			goto done;
		}

		// skip over the '%'
		fmt++;

		// reset formatting state
		flags = 0;
		width = 0;
		prec = -1;
		sign = '\0';

rflag:
		ch = *fmt++;
reswitch:
		switch(ch)
		{
		case '-':
			{
				flags |= LADJUST;
				goto rflag;
			}
		case '.':
			{
				n = 0;
				while(is_digit((ch = *fmt++)))
				{
					n = 10 * n + (ch - '0');
				}
				prec = (n < 0) ? -1 : n;
				goto reswitch;
			}
		case '0':
			{
				flags |= ZEROPAD;
				goto rflag;
			}
		case '1':
		case '2':
		case '3':
		case '4':
		case '5':
		case '6':
		case '7':
		case '8':
		case '9':
			{
				n = 0;
				do
				{
					n = 10 * n + (ch - '0');
					ch = *fmt++;
				} while(is_digit(ch));
				width = n;
				goto reswitch;
			}
		case 'c':
			{
				CHECK_ARGS(0);
				if (!llen)
				{
					goto done;
				}
				char *c;
				pCtx->LocalToString(params[arg], &c);
				*buf_p++ = *c;
				llen--;
				arg++;
				break;
			}
		case 'b':
			{
				CHECK_ARGS(0);
				cell_t *value;
				pCtx->LocalToPhysAddr(params[arg], &value);
				AddBinary(&buf_p, llen, *value, width, flags);
				arg++;
				break;
			}
		case 'd':
		case 'i':
			{
				CHECK_ARGS(0);
				cell_t *value;
				pCtx->LocalToPhysAddr(params[arg], &value);
				AddInt(&buf_p, llen, static_cast<int>(*value), width, flags);
				arg++;
				break;
			}
		case 'u':
			{
				CHECK_ARGS(0);
				cell_t *value;
				pCtx->LocalToPhysAddr(params[arg], &value);
				AddUInt(&buf_p, llen, static_cast<unsigned int>(*value), width, flags);
				arg++;
				break;
			}
		case 'f':
			{
				CHECK_ARGS(0);
				cell_t *value;
				pCtx->LocalToPhysAddr(params[arg], &value);
				AddFloat(&buf_p, llen, sp_ctof(*value), width, prec, flags);
				arg++;
				break;
			}
		case 'L':
			{
				CHECK_ARGS(0);
				cell_t *value;
				pCtx->LocalToPhysAddr(params[arg], &value);
				char buffer[255];
				if (*value)
				{
					CPlayer *player = g_Players.GetPlayerByIndex(*value);
					if (!player || !player->IsConnected())
					{
						return pCtx->ThrowNativeError("Client index %d is invalid", *value);
					}
					const char *auth = player->GetAuthString();
					if (!auth || auth[0] == '\0')
					{
						auth = "STEAM_ID_PENDING";
					}
					int userid = engine->GetPlayerUserId(player->GetEdict());
					UTIL_Format(buffer, 
						sizeof(buffer), 
						"%s<%d><%s><>", 
						player->GetName(),
						userid,
						auth);
				}
				else
				{
					UTIL_Format(buffer,
						sizeof(buffer),
						"Console<0><Console><Console>");
				}
				AddString(&buf_p, llen, buffer, width, prec);
				arg++;
				break;
			}
		case 'N':
			{
				CHECK_ARGS(0);
				cell_t *value;
				pCtx->LocalToPhysAddr(params[arg], &value);

				const char *name = "Console";
				if (*value)
				{
					CPlayer *player = g_Players.GetPlayerByIndex(*value);
					if (!player || !player->IsConnected())
					{
						return pCtx->ThrowNativeError("Client index %d is invalid", *value);
					}
					name = player->GetName();
				}
				AddString(&buf_p, llen, name, width, prec);
				arg++;
				break;
			}
		case 's':
			{
				CHECK_ARGS(0);
				char *str;
				int err;
				if ((err=pCtx->LocalToString(params[arg], &str)) != SP_ERROR_NONE)
				{
					pCtx->ThrowNativeErrorEx(err, "Could not deference string");
					return 0;
				}
				AddString(&buf_p, llen, str, width, prec);
				arg++;
				break;
			}
		case 'T':
			{
				CHECK_ARGS(1);
				char *key;
				bool error;
				size_t res;
				cell_t *target;
				pCtx->LocalToString(params[arg++], &key);
				pCtx->LocalToPhysAddr(params[arg++], &target);
				res = Translate(buf_p, llen, pCtx, key, *target, params, &arg, &error);
				if (error)
				{
					return 0;
				}
				buf_p += res;
				llen -= res;
				break;
			}
		case 't':
			{
				CHECK_ARGS(0);
				char *key;
				bool error;
				size_t res;
				cell_t target = g_SourceMod.GetGlobalTarget();
				pCtx->LocalToString(params[arg++], &key);
				res = Translate(buf_p, llen, pCtx, key, target, params, &arg, &error);
				if (error)
				{
					return 0;
				}
				buf_p += res;
				llen -= res;
				break;
			}
		case 'X':
			{
				CHECK_ARGS(0);
				cell_t *value;
				pCtx->LocalToPhysAddr(params[arg], &value);
				flags |= UPPERDIGITS;
				AddHex(&buf_p, llen, static_cast<unsigned int>(*value), width, flags);
				arg++;
				break;
			}
		case 'x':
			{
				CHECK_ARGS(0);
				cell_t *value;
				pCtx->LocalToPhysAddr(params[arg], &value);
				AddHex(&buf_p, llen, static_cast<unsigned int>(*value), width, flags);
				arg++;
				break;
			}
		case '%':
			{
				if (!llen)
				{
					goto done;
				}
				*buf_p++ = ch;
				llen--;
				break;
			}
		case '\0':
			{
				if (!llen)
				{
					goto done;
				}
				*buf_p++ = '%';
				llen--;
				goto done;
			}
		default:
			{
				if (!llen)
				{
					goto done;
				}
				*buf_p++ = ch;
				llen--;
				break;
			}
		}
	}

done:
	*buf_p = '\0';
	*param = arg;
	return (maxlen - llen - 1);
}
コード例 #22
0
size_t gnprintf(char *buffer, size_t maxlen, const char *format, void **args)
{
	if (!buffer || !maxlen)
	{
		return 0;
	}

	int arg = 0;
	char *buf_p;
	char ch;
	int flags;
	int width;
	int prec;
	int n;
	char sign;
	const char *fmt;
	size_t llen = maxlen - 1;

	buf_p = buffer;
	fmt = format;

	while (true)
	{
		// run through the format string until we hit a '%' or '\0'
		for (ch = *fmt; llen && ((ch = *fmt) != '\0') && (ch != '%'); fmt++)
		{
			*buf_p++ = ch;
			llen--;
		}
		if ((ch == '\0') || (llen <= 0))
		{
			goto done;
		}

		// skip over the '%'
		fmt++;

		// reset formatting state
		flags = 0;
		width = 0;
		prec = -1;
		sign = '\0';

rflag:
		ch = *fmt++;
reswitch:
		switch(ch)
		{
		case '-':
			{
				flags |= LADJUST;
				goto rflag;
			}
		case '.':
			{
				n = 0;
				while(is_digit((ch = *fmt++)))
				{
					n = 10 * n + (ch - '0');
				}
				prec = (n < 0) ? -1 : n;
				goto reswitch;
			}
		case '0':
			{
				flags |= ZEROPAD;
				goto rflag;
			}
		case '1':
		case '2':
		case '3':
		case '4':
		case '5':
		case '6':
		case '7':
		case '8':
		case '9':
			{
				n = 0;
				do
				{
					n = 10 * n + (ch - '0');
					ch = *fmt++;
				} while(is_digit(ch));
				width = n;
				goto reswitch;
			}
		case 'c':
			{
				if (!llen)
				{
					goto done;
				}
				char *c = (char *)args[arg];
				*buf_p++ = *c;
				llen--;
				arg++;
				break;
			}
		case 'b':
			{
				int *value = (int *)args[arg];
				AddBinary(&buf_p, llen, *value, width, flags);
				arg++;
				break;
			}
		case 'd':
		case 'i':
			{
				int *value = (int *)args[arg];
				AddInt(&buf_p, llen, *value, width, flags);
				arg++;
				break;
			}
		case 'u':
			{
				unsigned int *value = (unsigned int *)args[arg];
				AddUInt(&buf_p, llen, *value, width, flags);
				arg++;
				break;
			}
		case 'f':
			{
				float *value = (float *)args[arg];
				AddFloat(&buf_p, llen, *value, width, prec, flags);
				arg++;
				break;
			}
		case 's':
			{
				const char *str = (const char *)args[arg];
				AddString(&buf_p, llen, str, width, prec);
				arg++;
				break;
			}
		case 'X':
			{
				unsigned int *value = (unsigned int *)args[arg];
				flags |= UPPERDIGITS;
				AddHex(&buf_p, llen, *value, width, flags);
				arg++;
				break;
			}
		case 'x':
			{
				unsigned int *value = (unsigned int *)args[arg];
				AddHex(&buf_p, llen, *value, width, flags);
				arg++;
				break;
			}
		case '%':
			{
				if (!llen)
				{
					goto done;
				}
				*buf_p++ = ch;
				llen--;
				break;
			}
		case '\0':
			{
				if (!llen)
				{
					goto done;
				}
				*buf_p++ = '%';
				llen--;
				goto done;
			}
		default:
			{
				if (!llen)
				{
					goto done;
				}
				*buf_p++ = ch;
				llen--;
				break;
			}
		}
	}

done:
	*buf_p = '\0';

	return (maxlen - llen - 1);
}
コード例 #23
0
ファイル: strlist.cpp プロジェクト: GDXN/Par-N-Rar
unsigned int StringList::AddString(const char *Str)
{
  return(AddString(Str,NULL));
}
コード例 #24
0
ファイル: ComboBox.cpp プロジェクト: ArchangelSDY/Qt7z
LRESULT CComboBox::AddString(LPCWSTR s)
{
  if (g_IsNT)
    return SendMsgW(CB_ADDSTRING, 0, (LPARAM)s);
  return AddString(GetSystemString(s));
}
コード例 #25
0
void CSettings::LoadDefaults()
{
	// jenksta: HACKY, find another way
#ifdef _SERVER
	AddString("logfile", "ivmp-svr.log");
	AddInteger("port", 9999, 1024, 65535);
	AddInteger("httpport", 9998, 80, 65535);
	AddString("httpserver", "");
	AddInteger("maxplayers", MAX_PLAYERS, 1, MAX_PLAYERS);
	AddInteger("maxvehicles", MAX_VEHICLES, 0, MAX_VEHICLES);
	AddString("password", "");
	AddBool("query", true);
	AddBool("listed", false);
	AddBool("guinametags",false);
	AddBool("vehicledamage", false);
	AddBool("vehiclewaterdeath", true);
	AddBool("headmovement",true);
	AddBool("checkGTAFiles",true);
	AddString("hostname", VERSION_IDENTIFIER_2 " Server");
	AddString("hostaddress", "");
	AddBool("frequentevents", false);
	AddBool("kickoldplayers", true);
	AddBool("paynspray", true);
	AddBool("autoaim", true);
	AddInteger("weather", 1, 1, 10);
	AddFloat("wind",0.0,0.0,50.0);
	AddBool("silent", false);
	AddBool("timestamp", true);
	AddList("script");
	AddList("clientscript");
	AddList("clientresource");
	AddList("module");
    AddList("config");
    AddString("masterlistpath", MASTERLIST_ADD_PATH);
#else
	AddString("ip", "127.0.0.1");
	AddInteger("port", 9999, 1024, 65535);
	AddString("currentconnect_server", "0.0.0.0");
	AddInteger("currentconnect_port", 9999, 1024, 65535);
	AddString("nick", "player");
	AddString("pass", "");
	AddBool("windowed", false);
	AddBool("fps", false);
	AddString("chatfont", "tahoma-bold");
	AddInteger("chatsize", 10, 1, 100);
	AddInteger("chatbga", 0, 0, 255);
	AddInteger("chatbgr", 0, 0, 255);
	AddInteger("chatbgg", 0, 0, 255);
	AddInteger("chatbgb", 0, 0, 255);
	AddString("masterlistpath", MASTERLIST_LIST_PATH);
#endif
	AddString("masterlist", MASTERLIST_ADDRESS);
	AddInteger("masterlistport", MASTERLIST_PORT, 1, 65535);
}
コード例 #26
0
ファイル: InPlaceList.cpp プロジェクト: KB3NZQ/hexedit4
CInPlaceList::CInPlaceList(CWnd* pParent, CRect& rect, DWORD dwStyle, UINT nID,
                           int nRow, int nColumn,
						   CStringArray& Items, CString sInitText,
						   UINT nFirstChar)
{
	m_nNumLines = 4;
	m_sInitText = sInitText;
 	m_nRow		= nRow;
 	m_nCol      = nColumn;
 	m_nLastChar = 0;
	m_bExitOnArrows = FALSE; //(nFirstChar != VK_LBUTTON);	// If mouse click brought us here,

	// Create the combobox
 	DWORD dwComboStyle = WS_BORDER|WS_CHILD|WS_VISIBLE|WS_VSCROLL|
 					     CBS_AUTOHSCROLL | dwStyle;
	int nHeight = rect.Height();
	rect.bottom = rect.bottom + m_nNumLines*nHeight + ::GetSystemMetrics(SM_CYHSCROLL);
	if (!Create(dwComboStyle, rect, pParent, nID)) return;

	// Add the strings
	for (int i = 0; i < Items.GetSize(); i++)
		AddString(Items[i]);

	// Get the maximum width of the text strings
	int nMaxLength = 0;
	CClientDC dc(GetParent());
	CFont* pOldFont = dc.SelectObject(pParent->GetFont());

	for (i = 0; i < Items.GetSize(); i++)
		nMaxLength = max(nMaxLength, dc.GetTextExtent(Items[i]).cx);

	nMaxLength += (::GetSystemMetrics(SM_CXVSCROLL) + dc.GetTextExtent(_T(" ")).cx*2);
	dc.SelectObject(pOldFont);

    if (nMaxLength > rect.Width())
	    rect.right = rect.left + nMaxLength;

	// Resize the edit window and the drop down window
	MoveWindow(rect);

	SetFont(pParent->GetFont());
	SetItemHeight(-1, nHeight);

	SetDroppedWidth(nMaxLength);
	SetHorizontalExtent(0); // no horz scrolling

	// Set the initial text to m_sInitText
	if (SelectString(-1, m_sInitText) == CB_ERR)
		SetWindowText(m_sInitText);		// No text selected, so restore what was there before

    // Subclass the combobox edit control if style includes CBS_DROPDOWN
    if ((dwStyle & CBS_DROPDOWNLIST) != CBS_DROPDOWNLIST)
    {
        m_edit.SubclassDlgItem(IDC_COMBOEDIT, this);
 	    SetFocus();
        switch (nFirstChar)
        {
            case VK_LBUTTON:
            case VK_RETURN:   m_edit.SetSel((int)_tcslen(m_sInitText), -1); return;
            case VK_BACK:     m_edit.SetSel((int)_tcslen(m_sInitText), -1); break;
            case VK_DOWN:
            case VK_UP:
            case VK_RIGHT:
            case VK_LEFT:
            case VK_NEXT:
            case VK_PRIOR:
            case VK_HOME:
            case VK_END:      m_edit.SetSel(0,-1); return;
            default:          m_edit.SetSel(0,-1);
        }
        SendMessage(WM_CHAR, nFirstChar);
    }
    else
 	    SetFocus();
}
コード例 #27
0
char* DB2DatabaseLoader::Load(uint32& records, char**& indexTable, char*& stringHolders, std::vector<char*>& stringPool)
{
    // Even though this query is executed only once, prepared statement is used to send data from mysql server in binary format
    PreparedQueryResult result = HotfixDatabase.Query(HotfixDatabase.GetPreparedStatement(_loadInfo->Statement));
    if (!result)
        return nullptr;

    if (_loadInfo->Meta->GetDbFieldCount() != result->GetFieldCount())
        return nullptr;

    // get struct size and index pos
    uint32 indexField = _loadInfo->Meta->GetDbIndexField();
    uint32 recordSize = _loadInfo->Meta->GetRecordSize();

    // we store flat holders pool as single memory block
    std::size_t stringFields = _loadInfo->GetStringFieldCount(false);
    std::size_t localizedStringFields = _loadInfo->GetStringFieldCount(true);

    // each string field at load have array of string for each locale
    std::size_t stringHoldersRecordPoolSize = localizedStringFields * sizeof(LocalizedString) + (stringFields - localizedStringFields) * sizeof(char*);

    if (stringFields)
    {
        std::size_t stringHoldersPoolSize = stringHoldersRecordPoolSize * result->GetRowCount();
        stringHolders = new char[stringHoldersPoolSize];

        // DB2 strings expected to have at least empty string
        for (std::size_t i = 0; i < stringHoldersPoolSize / sizeof(char*); ++i)
            ((char const**)stringHolders)[i] = nullStr;
    }
    else
        stringHolders = nullptr;

    // Resize index table
    // database query *MUST* contain ORDER BY `index_field` DESC clause
    uint32 indexTableSize = (*result)[indexField].GetUInt32() + 1;
    if (indexTableSize < records)
        indexTableSize = records;

    if (indexTableSize > records)
    {
        char** tmpIdxTable = new char*[indexTableSize];
        memset(tmpIdxTable, 0, indexTableSize * sizeof(char*));
        memcpy(tmpIdxTable, indexTable, records * sizeof(char*));
        delete[] indexTable;
        indexTable = tmpIdxTable;
    }

    char* tempDataTable = new char[result->GetRowCount() * recordSize];
    uint32* newIndexes = new uint32[result->GetRowCount()];
    uint32 rec = 0;
    uint32 newRecords = 0;

    do
    {
        Field* fields = result->Fetch();
        uint32 offset = 0;
        uint32 stringFieldOffset = 0;

        uint32 indexValue = fields[indexField].GetUInt32();

        // Attempt to overwrite existing data
        char* dataValue = indexTable[indexValue];
        if (!dataValue)
        {
            newIndexes[newRecords] = indexValue;
            dataValue = &tempDataTable[newRecords++ * recordSize];
        }

        uint32 f = 0;
        if (!_loadInfo->Meta->HasIndexFieldInData())
        {
            *((uint32*)(&dataValue[offset])) = indexValue;
            offset += 4;
            ++f;
        }

        for (uint32 x = 0; x < _loadInfo->Meta->FieldCount; ++x)
        {
            for (uint32 z = 0; z < _loadInfo->Meta->ArraySizes[x]; ++z)
            {
                switch (_loadInfo->TypesString[f])
                {
                    case FT_FLOAT:
                        *((float*)(&dataValue[offset])) = fields[f].GetFloat();
                        offset += 4;
                        break;
                    case FT_INT:
                        *((int32*)(&dataValue[offset])) = fields[f].GetInt32();
                        offset += 4;
                        break;
                    case FT_BYTE:
                        *((int8*)(&dataValue[offset])) = fields[f].GetInt8();
                        offset += 1;
                        break;
                    case FT_SHORT:
                        *((int16*)(&dataValue[offset])) = fields[f].GetInt16();
                        offset += 2;
                        break;
                    case FT_LONG:
                        *((int64*)(&dataValue[offset])) = fields[f].GetInt64();
                        offset += 8;
                        break;
                    case FT_STRING:
                    {
                        LocalizedString** slot = (LocalizedString**)(&dataValue[offset]);
                        *slot = (LocalizedString*)(&stringHolders[stringHoldersRecordPoolSize * rec + stringFieldOffset]);
                        ASSERT(*slot);

                        // Value in database in main table field must be for enUS locale
                        if (char* str = AddString(&(*slot)->Str[LOCALE_enUS], fields[f].GetString()))
                            stringPool.push_back(str);

                        stringFieldOffset += sizeof(LocalizedString);
                        offset += sizeof(char*);
                        break;
                    }
                    case FT_STRING_NOT_LOCALIZED:
                    {
                        char const** slot = (char const**)(&dataValue[offset]);
                        *slot = (char*)(&stringHolders[stringHoldersRecordPoolSize * rec + stringFieldOffset]);
                        ASSERT(*slot);

                        // Value in database in main table field must be for enUS locale
                        if (char* str = AddString(slot, fields[f].GetString()))
                            stringPool.push_back(str);

                        stringFieldOffset += sizeof(char*);
                        offset += sizeof(char*);
                        break;
                    }
                    default:
                        ASSERT(false, "Unknown format character '%c' found in %s meta", _loadInfo->TypesString[x], _storageName.c_str());
                        break;
                }
                ++f;
            }
        }

        ASSERT(offset == recordSize);
        ++rec;
    } while (result->NextRow());

    if (!newRecords)
    {
        delete[] tempDataTable;
        delete[] newIndexes;
        return nullptr;
    }

    // Compact new data table to only contain new records not previously loaded from file
    char* dataTable = new char[newRecords * recordSize];
    memcpy(dataTable, tempDataTable, newRecords * recordSize);

    // insert new records to index table
    for (uint32 i = 0; i < newRecords; ++i)
        indexTable[newIndexes[i]] = &dataTable[i * recordSize];

    delete[] tempDataTable;
    delete[] newIndexes;

    records = indexTableSize;

    return dataTable;
}
コード例 #28
0
ファイル: UICompound.cpp プロジェクト: RocketersAlex/LCSource
// ----------------------------------------------------------------------------
// Name : AddString()
// Desc :
// ----------------------------------------------------------------------------
void CUICompound::AddString( CTString &strDesc )
{
	if( m_nStringCount >= MAX_COMPOUND_STRING )
		return;

	// Get length of string
	INDEX	nLength = strDesc.Length();
	if( nLength == 0 )
		return;
	// wooss 051002
#if defined(G_THAI)
	{
		int		iPos;
		// Get length of string
		INDEX	nThaiLen = FindThaiLen(strDesc);
		INDEX	nChatMax= (_iMaxMsgStringChar-1)*(_pUIFontTexMgr->GetFontWidth()+_pUIFontTexMgr->GetFontSpacing());
		if( nLength == 0 )
			return;
		// If length of string is less than max char
		if( nThaiLen <= nChatMax )
		{
		// Check line character
			for( iPos = 0; iPos < nLength; iPos++ )
			{
				if( strDesc[iPos] == '\n' || strDesc[iPos] == '\r' )
					break;
			}

			// Not exist
			if( iPos == nLength )
				m_strDesc[m_nStringCount++] = strDesc;
			else
			{
				// Split string
				CTString	strTemp;
				strDesc.Split( iPos, m_strDesc[m_nStringCount++], strTemp );

				// Trim line character
				if( strTemp[0] == '\r' && strTemp[1] == '\n' )
					strTemp.TrimLeft( strTemp.Length() - 2 );
				else
					strTemp.TrimLeft( strTemp.Length() - 1 );

				AddString( strTemp );
			}
		}
		// Need multi-line
		else
		{
			// Check splitting position for 2 byte characters
			int		nSplitPos = _iMaxMsgStringChar;
			BOOL	b2ByteChar = FALSE;
			for( iPos = 0; iPos < nLength; iPos++ )
			{
				if(nChatMax < FindThaiLen(strDesc,0,iPos))
					break;
			}
			nSplitPos = iPos;

			// Check line character
			for( iPos = 0; iPos < nSplitPos; iPos++ )
			{
				if( strDesc[iPos] == '\n' || strDesc[iPos] == '\r' )
					break;
			}

			// Not exist
			if( iPos == nSplitPos )
			{
				// Split string
				CTString	strTemp;
				strDesc.Split( nSplitPos, m_strDesc[m_nStringCount++], strTemp );

				// Trim space
				if( strTemp[0] == ' ' )
				{
					int	nTempLength = strTemp.Length();
					for( iPos = 1; iPos < nTempLength; iPos++ )
					{
						if( strTemp[iPos] != ' ' )
							break;
					}

					strTemp.TrimLeft( strTemp.Length() - iPos );
				}

				AddString( strTemp );
			}
			else
			{
				// Split string
				CTString	strTemp;
				strDesc.Split( iPos, m_strDesc[m_nStringCount++], strTemp );

				// Trim line character
				if( strTemp[0] == '\r' && strTemp[1] == '\n' )
					strTemp.TrimLeft( strTemp.Length() - 2 );
				else
					strTemp.TrimLeft( strTemp.Length() - 1 );

				AddString( strTemp );
			}

		}
		
	}
#else
	{	
		// If length of string is less than max char
		if( nLength <= _iMaxMsgStringChar )
		{
			// Check line character
			int iPos;
			for( iPos = 0; iPos < nLength; iPos++ )
			{
				if( strDesc[iPos] == '\n' || strDesc[iPos] == '\r' )
					break;
			}

			// Not exist
			if( iPos == nLength )
				m_strDesc[m_nStringCount++] = strDesc;
			else
			{
				// Split string
				CTString	strTemp;
				strDesc.Split( iPos, m_strDesc[m_nStringCount++], strTemp );

				// Trim line character
				if( strTemp[0] == '\r' && strTemp[1] == '\n' )
					strTemp.TrimLeft( strTemp.Length() - 2 );
				else
					strTemp.TrimLeft( strTemp.Length() - 1 );

				AddString( strTemp );
			}
		}
		// Need multi-line
		else
		{
			// Check splitting position for 2 byte characters
			int		nSplitPos = _iMaxMsgStringChar;
			BOOL	b2ByteChar = FALSE;
			int		iPos;
			for( iPos = 0; iPos < nSplitPos; iPos++ )
			{
				if( strDesc[iPos] & 0x80 )
					b2ByteChar = !b2ByteChar;
				else
					b2ByteChar = FALSE;
			}

			if( b2ByteChar )
				nSplitPos--;

			// Check line character
			for( iPos = 0; iPos < nSplitPos; iPos++ )
			{
				if( strDesc[iPos] == '\n' || strDesc[iPos] == '\r' )
					break;
			}

			// Not exist
			if( iPos == nSplitPos )
			{
				// Split string
				CTString	strTemp;
				strDesc.Split( nSplitPos, m_strDesc[m_nStringCount++], strTemp );

				// Trim space
				if( strTemp[0] == ' ' )
				{
					int	nTempLength = strTemp.Length();
					for( iPos = 1; iPos < nTempLength; iPos++ )
					{
						if( strTemp[iPos] != ' ' )
							break;
					}

					strTemp.TrimLeft( strTemp.Length() - iPos );
				}

				AddString( strTemp );
			}
			else
			{
				// Split string
				CTString	strTemp;
				strDesc.Split( iPos, m_strDesc[m_nStringCount++], strTemp );

				// Trim line character
				if( strTemp[0] == '\r' && strTemp[1] == '\n' )
					strTemp.TrimLeft( strTemp.Length() - 2 );
				else
					strTemp.TrimLeft( strTemp.Length() - 1 );

				AddString( strTemp );
			}
		}
	}
#endif
}
コード例 #29
0
ファイル: UICompound.cpp プロジェクト: RocketersAlex/LCSource
// ----------------------------------------------------------------------------
// Name : Create()
// Desc :
// ----------------------------------------------------------------------------
void CUICompound::Create( CUIWindow *pParentWnd, int nX, int nY, int nWidth, int nHeight )
{
	CUIWindow::Create(pParentWnd, nX, nY, nWidth, nHeight);

	_iMaxMsgStringChar = 187 / ( _pUIFontTexMgr->GetFontWidth() + _pUIFontTexMgr->GetFontSpacing() );

	// Region of each part
	m_rcTitle.SetRect( 0, 0, 216, 22 );
	
	m_rcItemSlot[0].SetRect( 66, 0, 66 + COMPOUND_ITEM_SLOT_SIZE, 0 );
	m_rcItemSlot[1].SetRect( 116, 0, 116 + COMPOUND_ITEM_SLOT_SIZE, 0 );
	m_rcItemSlot[2].SetRect( 91, 0, 91 + COMPOUND_ITEM_SLOT_SIZE, 0 );

	m_rcInsertItem.SetRect( 3, 0, 213, 0 );

	// Create Compound texture
	m_ptdBaseTexture = CreateTexture( CTString( "Data\\Interface\\MessageBox.tex" ) );
	FLOAT	fTexWidth	= m_ptdBaseTexture->GetPixWidth();
	FLOAT	fTexHeight	= m_ptdBaseTexture->GetPixHeight();

	// UV Coordinate of each part
	// Background
	m_rtTop.SetUV( 0, 0, 216, 26, fTexWidth, fTexHeight );
	m_rtMiddle1.SetUV( 0, 31, 216, 33, fTexWidth, fTexHeight );
	m_rtMiddle2.SetUV( 0, 35, 216, 37, fTexWidth, fTexHeight );
	m_rtBottom.SetUV( 0, 38, 216, 45, fTexWidth, fTexHeight );
	m_rtItemSlot.SetUV( 0, 68, 34, 102, fTexWidth, fTexHeight );

	// Close button
	m_btnClose.Create( this, CTString( "" ), 184, 4, 14, 14 );
	m_btnClose.SetUV( UBS_IDLE, 219, 0, 233, 14, fTexWidth, fTexHeight );
	m_btnClose.SetUV( UBS_CLICK, 234, 0, 248, 14, fTexWidth, fTexHeight );
	m_btnClose.CopyUV( UBS_IDLE, UBS_ON );
	m_btnClose.CopyUV( UBS_IDLE, UBS_DISABLE );

	// OK button
	m_btnOK.Create( this, _S( 191, "확인" ), 36, 154, 63, 21 );					
	m_btnOK.SetUV( UBS_IDLE, 0, 46, 63, 67, fTexWidth, fTexHeight );
	m_btnOK.SetUV( UBS_CLICK, 66, 46, 129, 67, fTexWidth, fTexHeight );
	m_btnOK.CopyUV( UBS_IDLE, UBS_ON );
	m_btnOK.CopyUV( UBS_IDLE, UBS_DISABLE );

	// Cancel button
	m_btnCancel.Create( this, _S( 139, "취소" ), 117, 154, 63, 21 );
	m_btnCancel.SetUV( UBS_IDLE, 0, 46, 63, 67, fTexWidth, fTexHeight );
	m_btnCancel.SetUV( UBS_CLICK, 66, 46, 129, 67, fTexWidth, fTexHeight );
	m_btnCancel.CopyUV( UBS_IDLE, UBS_ON );
	m_btnCancel.CopyUV( UBS_IDLE, UBS_DISABLE );

	// Add string
	AddString( _S( 724, "합성할 일반제련석, 악세사리, 마법가루를 인벤토리에서 선택하여 넣어주십시오." ) );

	// Set region of slot item & money...
	int	nNewHeight = COMPOUND_DESC_TEXT_SY + ( m_nStringCount + 1 ) * _pUIFontTexMgr->GetLineHeight();
		
	m_rcItemSlot[0].Top = nNewHeight;
	m_rcItemSlot[0].Bottom = m_rcItemSlot[0].Top + COMPOUND_ITEM_SLOT_SIZE;

	m_rcItemSlot[1].Top = nNewHeight;
	m_rcItemSlot[1].Bottom = m_rcItemSlot[1].Top + COMPOUND_ITEM_SLOT_SIZE;

	nNewHeight += 12 + COMPOUND_ITEM_SLOT_SIZE;

	m_rcItemSlot[2].Top = nNewHeight;
	m_rcItemSlot[2].Bottom = m_rcItemSlot[2].Top + COMPOUND_ITEM_SLOT_SIZE;

	nNewHeight += COMPOUND_ITEM_SLOT_SIZE + _pUIFontTexMgr->GetLineHeight();
	m_nTextRegionHeight = nNewHeight - COMPOUND_DESC_TEXT_SY + 8;

	m_rcInsertItem.Top = COMPOUND_DESC_TEXT_SY;
	m_rcInsertItem.Bottom = nNewHeight;

	nNewHeight += 6;
	m_btnOK.SetPosY( nNewHeight );
	m_btnCancel.SetPosY( nNewHeight );

	nNewHeight += m_btnOK.GetHeight() + 7;
	SetHeight( nNewHeight );

	// Slot item button
	for (int i  = 0; i < COMPOUND_ITEM_SLOT_COUNT; i++)
	{
		//m_pIconSlot[i].Create( this, m_rcItemSlot[i].Left + 1, m_rcItemSlot[i].Top + 1, BTN_SIZE, BTN_SIZE, UI_COMPOUND, UBET_ITEM );
		m_pIconSlot[i] = new CUIIcon();
		m_pIconSlot[i]->Create(this, m_rcItemSlot[i].Left + 1, m_rcItemSlot[i].Top + 1, BTN_SIZE, BTN_SIZE, UI_COMPOUND, UBET_ITEM);
	}
}
コード例 #30
0
ファイル: SkillEditListBox.cpp プロジェクト: DrDub/Byakhee
BOOL CSkillEditListBox::Initialise()
{
    //set the height of each list box element
    SetItemHeight( -1, 20 );

    //delete all existing strings
    ResetContent();

    //add all of the investigator's skills (or at least the occupational ones, if m_fOccupationalOnly == TRUE)
    if( m_pInvestigator == NULL )
    {
        ASSERT(FALSE);
        return FALSE;
    }

    for( int i = 0; i < m_pInvestigator->m_AllSkillList.GetSize(); i++ )
    {
        CInvestigatorSkill* pInvestigatorSkill = m_pInvestigator->m_AllSkillList.GetAt(i);
        SkillType Type = pInvestigatorSkill ? pInvestigatorSkill->m_pSkill->m_SkillType : NO_TYPE;
        if( pInvestigatorSkill && ( ( m_fOccupationalOnly == TRUE && pInvestigatorSkill->m_fOccupational ) || ( m_fOccupationalOnly == FALSE ) ) && pInvestigatorSkill->m_pSkill->IsEra(m_pInvestigator->m_Era) && ( ( m_fOccupationalOnly == FALSE && Type != ANYSKILL ) || ( m_fOccupationalOnly == TRUE ) ) && Type != NO_TYPE )
        {
            //prepare the string - trim leading *s or set special name
            CString strSkillName;
            switch( Type )
            {
                case ANYSKILL:
                    strSkillName = "(free choice)"; break;

                case SUBSKILL:
                {
                    //sort on this subskill's parent skill name
                    CSubSkill* pSubSkill = (CSubSkill*)pInvestigatorSkill->m_pSkill;
                    const char *pBuf = LPCSTR(pSubSkill->m_pSkill->m_strName);
                    while( *pBuf == '*' ) pBuf++;
                    strSkillName = pBuf;
                    break;
                }

                default:
                {
                    const char *pBuf = LPCSTR(pInvestigatorSkill->m_pSkill->m_strName);
                    while( *pBuf == '*' ) pBuf++;
                    strSkillName = pBuf;
                    break;
                }
            }
            
            //add the skill
            if( Type != SPECIALSKILL && *LPCSTR(pInvestigatorSkill->m_pSkill->m_strBase) != '*' ) //don't add special skill types
            {
                int nPosition = AddString( strSkillName );
			    if( nPosition != LB_ERR ) SetItemData( nPosition, (DWORD)pInvestigatorSkill );
            }
        }
    }

    //create the child controls if it doesn't exist
    if( !m_fCtrlInit )
    {
        m_fCtrlInit = TRUE;

        CRect rc; rc.SetRectEmpty();

        //create the edit control
        m_wndEditCtrl.Create( ES_NUMBER, rc, this, 0xFFFF );
        m_wndEditCtrl.ModifyStyleEx(0, WS_EX_STATICEDGE );

        //create the combo control
        m_wndComboCtrl.Create( CBS_DROPDOWN|CBS_SORT|WS_VSCROLL|CBS_AUTOHSCROLL, rc, this, 0xFFFF );
        m_wndComboCtrl.m_wndComboEditCtrl.SetOwnerList( this );

        //set the font on the child controls
        m_wndEditCtrl.SetFont( GetFont() );
        m_wndComboCtrl.SetFont( GetFont() );
    }


    return TRUE;
}