void CLayerTiles::Convert(CUIRect Rect, RECTi *pOut) { pOut->x = ConvertX(Rect.x); pOut->y = ConvertY(Rect.y); pOut->w = ConvertX(Rect.x+Rect.w+31) - pOut->x; pOut->h = ConvertY(Rect.y+Rect.h+31) - pOut->y; }
void CLayerTiles::FillSelection(bool Empty, CLayer *pBrush, CUIRect Rect) { if(m_Readonly) return; int sx = ConvertX(Rect.x); int sy = ConvertY(Rect.y); int w = ConvertX(Rect.w); int h = ConvertY(Rect.h); CLayerTiles *pLt = static_cast<CLayerTiles*>(pBrush); for(int y = 0; y <= h; y++) { for(int x = 0; x <= w; x++) { int fx = x+sx; int fy = y+sy; if(fx < 0 || fx >= m_Width || fy < 0 || fy >= m_Height) continue; if(Empty) m_pTiles[fy*m_Width+fx].m_Index = 1; else m_pTiles[fy*m_Width+fx] = pLt->m_pTiles[(y*pLt->m_Width + x%pLt->m_Width) % (pLt->m_Width*pLt->m_Height)]; } } m_pEditor->m_Map.m_Modified = true; }
void CLayerTiles::BrushDraw(CLayer *pBrush, float wx, float wy) { if(m_Readonly) return; // CLayerTiles *l = (CLayerTiles *)pBrush; int sx = ConvertX(wx); int sy = ConvertY(wy); for(int y = 0; y < l->m_Height; y++) for(int x = 0; x < l->m_Width; x++) { int fx = x+sx; int fy = y+sy; if(fx<0 || fx >= m_Width || fy < 0 || fy >= m_Height) continue; if (m_pEditor->m_BrushMode == BRUSH_MODE_ADDITION && l->m_pTiles[y*l->m_Width+x].m_Index == 0) continue; m_pTiles[fy*m_Width+fx] = l->m_pTiles[y*l->m_Width+x]; } m_pEditor->m_Map.m_Modified = true; }
void CLayerTiles::BrushDraw(CLayer *pBrush, float wx, float wy) { if(m_Readonly) return; // CLayerTiles *l = (CLayerTiles *)pBrush; int sx = ConvertX(wx); int sy = ConvertY(wy); for(int y = 0; y < l->m_Height; y++) for(int x = 0; x < l->m_Width; x++) { int fx = x+sx; int fy = y+sy; if(fx<0 || fx >= m_Width || fy < 0 || fy >= m_Height) continue; // dont allow tele in/out, speedup and switch tiles in game layer if(m_pEditor->GetSelectedLayer(0) == m_pEditor->m_Map.m_pGameLayer && (l->m_pTiles[y*l->m_Width+x].m_Index == TILE_TELEIN || l->m_pTiles[y*l->m_Width+x].m_Index == TILE_TELEINEVIL || l->m_pTiles[y*l->m_Width+x].m_Index == TILE_TELEOUT || l->m_pTiles[y*l->m_Width+x].m_Index == TILE_TELECHECK || l->m_pTiles[y*l->m_Width+x].m_Index == TILE_TELECHECKOUT || l->m_pTiles[y*l->m_Width+x].m_Index == TILE_TELECHECKIN || l->m_pTiles[y*l->m_Width+x].m_Index == TILE_BOOST || l->m_pTiles[y*l->m_Width+x].m_Index == TILE_SWITCHOPEN || l->m_pTiles[y*l->m_Width+x].m_Index == TILE_SWITCHCLOSE || l->m_pTiles[y*l->m_Width+x].m_Index == TILE_SWITCHTIMEDOPEN || l->m_pTiles[y*l->m_Width+x].m_Index == TILE_SWITCHTIMEDCLOSE || l->m_pTiles[y*l->m_Width+x].m_Index == (ENTITY_DOOR + ENTITY_OFFSET))) continue; m_pTiles[fy*m_Width+fx] = l->m_pTiles[y*l->m_Width+x]; } m_pEditor->m_Map.m_Modified = true; }
void CLayerTiles::BrushSelecting(CUIRect Rect) { Graphics()->TextureClear(); m_pEditor->Graphics()->QuadsBegin(); m_pEditor->Graphics()->SetColor(1.0f, 1.0f, 1.0f, 0.4f); Snap(&Rect); IGraphics::CQuadItem QuadItem(Rect.x, Rect.y, Rect.w, Rect.h); m_pEditor->Graphics()->QuadsDrawTL(&QuadItem, 1); m_pEditor->Graphics()->QuadsEnd(); char aBuf[16]; str_format(aBuf, sizeof(aBuf), "%d,%d", ConvertX(Rect.w), ConvertY(Rect.h)); TextRender()->Text(0, Rect.x+3.0f, Rect.y+3.0f, m_pEditor->m_ShowPicker?15.0f:15.0f*m_pEditor->m_WorldZoom, aBuf, -1); }
void CLayerTiles::BrushSelecting(CUIRect Rect) { vec4 FillColor = HexToRgba(g_Config.m_EdColorSelectionTile); Graphics()->TextureClear(); m_pEditor->Graphics()->QuadsBegin(); m_pEditor->Graphics()->SetColor(FillColor.r*FillColor.a, FillColor.g*FillColor.a, FillColor.b*FillColor.a, FillColor.a); Snap(&Rect); IGraphics::CQuadItem QuadItem(Rect.x, Rect.y, Rect.w, Rect.h); m_pEditor->Graphics()->QuadsDrawTL(&QuadItem, 1); m_pEditor->Graphics()->QuadsEnd(); char aBuf[16]; str_format(aBuf, sizeof(aBuf), "%d,%d", ConvertX(Rect.w), ConvertY(Rect.h)); TextRender()->Text(0, Rect.x+3.0f, Rect.y+3.0f, m_pEditor->m_ShowTilePicker?15.0f:15.0f*m_pEditor->m_WorldZoom, aBuf, -1); }
int Programmanalisator::parseCommand(QString* Kadr, int LNum) { QStringList Komm=Kadr->split(" ",QString::SkipEmptyParts); if (Komm.isEmpty()) return 0; // пропуск пустых строк if (Komm.first().at(0)==';') return 0; // комментарий if (Komm.first().contains(QRegExp("[0-9]{1,2}"))) Komm.removeFirst(); // отсекаем номер кадра qDebug()<<Komm; //1-я строка заготовки if ((Komm[0]=="BULK")&&(Komm[1]=="FORM")&&(Komm[2]=="0.1")) { Komm.removeFirst(); Komm.removeFirst(); Komm.removeFirst(); qDebug()<<Komm; if (ConvertX(&Komm.first(),&Q1)) Komm.removeFirst(); else return -1; if (ConvertY(&Komm.first(),&Q2)) Komm.removeFirst(); else return -1; if (ConvertZ(&Komm.first(),&Q3)) Komm.removeFirst(); else return -1; return BULK_FORM1; // конец обработки } else if ((Komm[0]=="BULK")&&(Komm[1]=="FORM")&&(Komm[2]=="0.2")) { // 2-я строка заготовки Komm.removeFirst(); Komm.removeFirst(); Komm.removeFirst(); qDebug()<<Komm; if (ConvertX(&Komm.first(),&Q4)) Komm.removeFirst(); else return -1; if (ConvertY(&Komm.first(),&Q5)) Komm.removeFirst(); else return -1; if (ConvertZ(&Komm.first(),&Q6)) Komm.removeFirst(); else return -1; return BULK_FORM2; } else if (Komm[0]=="L") { Komm.removeFirst(); if (ConvertIX(&Komm.first(),&Q1)) return FRES_IX; else if (ConvertX(&Komm.first(),&Q1)) return FRES_X; else if (ConvertIY(&Komm.first(),&Q1)) return FRES_IY; else if (ConvertY(&Komm.first(),&Q1)) return FRES_Y; else if (ConvertIZ(&Komm.first(),&Q1)) return FRES_IZ; else if (ConvertZ(&Komm.first(),&Q1)) return FRES_Z; else return -1; } else if ((Komm[0]=="TOOL")&&(Komm[1]=="CALL")) { bool res=false; if (Komm.at(3)=="Y") emit Vert_Hor(true); if (Komm.at(3)=="Z") emit Vert_Hor(false); I1=Komm.at(2).toInt(&res); if (res) return TOOL_CALL; else return -1; } else if (Komm[0]=="LBL") { bool res=false; int N = Komm.at(1).toInt(&res); if (!res) return -1; if (LBL_rep.contains(N)||(LBL_call.contains(N))||(LBL_lin.contains(N))) { errorMessage(tr("Метка ")+QString::number(N)+tr(" задана дважды")); return -2; } if (!LBL_rep.contains(N)) LBL_rep.insert(N, 0); if (!LBL_call.contains(N)) LBL_call.insert(N, false); if (!LBL_lin.contains(N)) LBL_lin.insert(N, LNum); return LBL_SET; } else if (Komm[0]=="CALL"&&Komm[1]=="LBL") { bool res=false; int N = Komm.at(2).toInt(&res); if (!res) return -1; if (LBL_call.contains(N)) { if (!LBL_call[N]) { bool res = false; QString s=Komm.at(3); LBL_rep[N]=s.remove(0,3).toInt(&res); if (!res) return -1; LBL_call[N]=true; I1=N; return LBL_CALL; } else { LBL_rep[N]--; if (LBL_rep[N]!=0) return LBL_CALL; } } } return 0; // неопознанная команда }