//XYZZY - temporary? void BlitTransparent( Img const& srcimg, Box const& srcbox, Palette const& srcpalette, Img& destimg, Box& destbox, PenColour const& transparentcolour ) { switch(srcimg.Fmt()) { case FMT_I8: assert(transparentcolour.IdxValid()); //assert(srcpalette!=0); BlitI8Keyed(srcimg,srcbox,srcpalette, destimg, destbox, transparentcolour.idx()); return; case FMT_RGBX8: if (destimg.Fmt() != FMT_I8) BlitRGBX8Keyed(srcimg,srcbox, destimg, destbox, transparentcolour.rgb()); return; case FMT_RGBA8: if (destimg.Fmt() != FMT_I8) BlitRGBA8Keyed(srcimg, srcbox, destimg, destbox); return; default: assert(false); } }
void Sporulation::SporeGen(Img& I, double *weather, double rate){ //unsigned seed = std::chrono::system_clock::now().time_since_epoch().count(); //std::default_random_engine generator(seed); int height = I.getHeight(); int width = I.getWidth(); if(!sp){ sp = (int **)CPLMalloc(sizeof(int *) * height); int *stream = (int *)CPLMalloc(sizeof(int)*width*height); for(int i=0;i<height;i++){ sp[i] = &stream[i*width]; } } for(int i=0;i<height;i++){ for(int j=0;j<width;j++){ if(I.data[i][j]>0){ double lambda = rate * weather[i*width+j]; int sum=0; poisson_distribution<int> distribution(lambda); for(int k=0;k<I.data[i][j];k++){ sum += distribution(generator); } sp[i][j] = sum; } } } }
int main( int argc, char *argv[] ) { if (argc != 3) cout << "usage:\n\tunfold INPUT_FILE OUTPUT_FILE\n"; Img input(argv[1]); Unfolder unfolder; Img *output = NULL; Img *debug = unfolder.unfold(input, output, true); // // Now rotate the image by 90 degrees. // int width = output->getWidth(); // Img* rotated = ImgOps::rotate(output, width/4, NULL); // Write output image to file. output->save(string(argv[2])); // Write debug image to file. debug->save("debug.jpg"); // Display the debug image. // ImgWindow window("Unfolder debug image"); // window.setImg(*debug); // window.refresh(); ImgWindow::waitAll(); return 0; }
template<class T> static void draw_points(Img<T> &img, const icl64f &value, std::vector<Point32f> &approx){ T *d = img.getData(0); int lineStep = img.getLineStep(); for(std::vector<Point32f>::iterator it = approx.begin(); it != approx.end(); ++it){ *(d + (int)(it->y) * lineStep + (int)(it->x)) = value; } }
void init(int offset) { for(int j=offset;j<dstim->h;j++) for(int i=offset;i<dstim->w;i++) { int x = rand()%srcim->w; int y = rand()%srcim->h; dstz->p(i,j) = srcim->ij_to_idx(x,y); x = rand()%srcim->w; y = rand()%srcim->h; //dsto->p(i,j) = srcim->ij_to_idx(x,y); dstim->p(i,j) = srcim->p(x,y); } }
// blit an RGBA img, blending with src alpha onto the dest (must be RGBX8 or RGBA8) void BlitRGBA8( Img const& srcimg, Box const& srcbox, Img& destimg, Box& destbox ) { assert(srcimg.Fmt()==FMT_RGBA8); assert(destimg.Fmt()!=FMT_I8); Box destclipped( destbox ); Box srcclipped( srcbox ); clip_blit( srcimg.Bounds(), srcclipped, destimg.Bounds(), destclipped ); const int w = destclipped.w; int y; for( y=0; y<destclipped.h; ++y ) { RGBA8 const* src = srcimg.PtrConst_RGBA8( srcclipped.x+0, srcclipped.y+y ); switch(destimg.Fmt()) { case FMT_I8: assert(false); // not implemented break; case FMT_RGBX8: scan_RGBA8_RGBX8(src, destimg.Ptr_RGBX8(destclipped.x+0,destclipped.y+y), w); break; case FMT_RGBA8: scan_RGBA8_RGBA8(src, destimg.Ptr_RGBA8(destclipped.x+0,destclipped.y+y), w); break; default: assert(false); break; } } destbox = destclipped; }
// blit an RGBA img, blending matte colour with src alpha onto the dest void BlitMatteRGBA8( Img const& srcimg, Box const& srcbox, Img& destimg, Box& destbox, PenColour const& matte ) { assert(srcimg.Fmt()==FMT_RGBA8); Box destclipped( destbox ); Box srcclipped( srcbox ); clip_blit( srcimg.Bounds(), srcclipped, destimg.Bounds(), destclipped ); const int w = destclipped.w; int y; for( y=0; y<destclipped.h; ++y ) { RGBA8 const* src = srcimg.PtrConst_RGBA8( srcclipped.x+0, srcclipped.y+y ); switch(destimg.Fmt()) { case FMT_I8: scan_matte_RGBA8_I8(src, destimg.Ptr_I8(destclipped.x+0,destclipped.y+y), w, matte.idx()); break; case FMT_RGBX8: scan_matte_RGBA8_RGBX8(src, destimg.Ptr_RGBX8(destclipped.x+0,destclipped.y+y), w, matte.rgb()); break; case FMT_RGBA8: scan_matte_RGBA8_RGBA8(src, destimg.Ptr_RGBA8(destclipped.x+0,destclipped.y+y), w, matte.rgb()); break; default: assert(false); break; } } destbox = destclipped; }
unsigned estep(int offset) { unsigned E=0; for(int j=offset;j<dstim->h;j++) for(int i=offset;i<dstim->w;i++) { unsigned bestdiff = ~0, bestidx = 0; // x,y are the target patch (in the z array) //int x,y; srcim->idx_to_ij(dstz->p(i,j),x,y); // we search our candidate set k from the pixel's current source nn_search(dstim, i,j, srck[dstz->p(i,j)], 0,0, bestdiff, bestidx); E += bestdiff; dstim->p(i,j) = srcim->p(bestidx); dstz->p(i,j) = bestidx; } return E; }
unsigned mstep(int offset) { unsigned E=0; bool changed = false; for(int j=offset;j<dstim->h;j++) for(int i=offset;i<dstim->w;i++) { // search k set of all neighborhood pixels to find best matching // neighborhood between src and dest(i,j) unsigned bestdiff = ~0, bestidx = 0; for(int nj=-Nsize;nj<=Nsize;nj++) for(int ni=-Nsize;ni<=Nsize;ni++) { int x=dstim->wrapw(i+ni), y=dstim->wraph(j+nj); nn_search(dstim, i,j, srck[dstz->p(x,y)], -ni,-nj, bestdiff, bestidx); } E += bestdiff; if(dstz->p(i,j) != bestidx) { changed = true; dstz->p(i,j) = bestidx; } dstim->p(i,j) = srcim->p(bestidx); } if(!changed) return 0; return E; }
VectorImgFilter::AutoImg VectorImgFilter::removeVerticals(const Img &vi, double prec) { AutoImg aImg( new VectorImg( vi.linesCnt() ) ); Img &img=*aImg.get(); // helper reference for(unsigned int i=0; i<vi.linesCnt(); ++i) { const Line2DCont &l =vi[i]; // get i-th line const Point2DCont &p1=l.getFrom(); // get first of 2 points const Point2DCont &p2=l.getTo(); // get second of 2 points if( fabs(p1[0]-p2[0])>prec ) // line is NOT vertical? img.add(l); // add line to output }; return aImg; };
// nearest neighbor search, using a given coherence set void nn_search(Img *destim, int di, int dj, const Kcoherence<K> &kset, int offx, int offy, unsigned &bestdiff,unsigned &bestidx) { for(int k=0;k<kset.n;k++) { int i,j; srcim->idx_to_ij(kset[k],i,j); i = srcim->wrapw(i+offx); j = srcim->wraph(j+offy); if(!srcwrap && (i<Nsize || i>=srcim->w-Nsize)) continue; if(!srcwrap && (j<Nsize || j>=srcim->h-Nsize)) continue; unsigned diff = neighbor_diff(destim, srcim, di,dj, i,j, Nsize); if(diff < bestdiff) { bestdiff = diff; bestidx = srcim->ij_to_idx(i,j); } } }
int main() { float scale = 400.f; float offset_x = 5.9f; float offset_y = 5.1f; float offset_z = 0.05f; float lacunarity = 1.99f; float persistance = 0.5f; Img img; while (!img.is_closed()) { Measure measure; measure.start(); const SimplexNoise simplex(0.1f/scale, 0.5f, lacunarity, persistance); // Amplitude of 0.5 for the 1st octave : sum ~1.0f const int octaves = static_cast<int>(5 + std::log(scale)); // Estimate number of octaves needed for the current scale std::ostringstream title; title << "2D Simplex Perlin noise (" << octaves << " octaves)"; img.set_title(title.str().c_str()); for (int row = 0; row < img.height(); ++row) { const float y = static_cast<float>(row - img.height()/2 + offset_y*scale); for (int col = 0; col < img.width(); ++col) { const float x = static_cast<float>(col - img.width()/2 + offset_x*scale); // TODO(SRombauts): Add 'erosion' with simple smoothing like exponential, and other 'modifiers' like in libnoise // Generate "biomes", ie smooth geographic variation in frequency & amplitude, // and add smaller details, summing the noise values for the coordinate const float noise = simplex.fractal(octaves, x, y) + offset_z; const color3f color = ramp(noise); // convert to color img.draw_point(col, row, (float*)&color); } } img.display(); const double diff_ms = measure.get(); std::cout << std::fixed << diff_ms << "ms\n"; img.user(scale, offset_x, offset_y, offset_z, lacunarity, persistance); } return 0; }
void FiltMedImg(const Img& in, const int k_width, const int k_height, const int channel, Img& out) { const int width = in.width(); const int height = in.height(); const int num_channel = in.channel(); assert(num_channel > channel); out.Reshape(width, height, 1); const double* in_data = in.data(); double* out_data = out.mutable_data(); for(int h = 0; h < height; h++) { for (int w = 0; w < width; w++) { int w_start = w - ((k_width) / 2); int h_start = h - ((k_height) / 2); int kw_start = 0; int kh_start = 0; int kw_end = k_width; int kh_end = k_height; std::vector<double> temp_list; for (int i = kh_start; i < kh_end; i++ ) { for (int j = kw_start; j < kw_end; j++) { int w_temp = w_start + j; int h_temp = h_start + i; if (w_temp >=0 && w_temp < width && h_temp >= 0 && h_temp < height) { temp_list.push_back(in_data[h_temp * width + w_temp]); } } } std::sort(temp_list.begin(), temp_list.end()); out_data[h * width + w] = temp_list[temp_list.size()/2]; } } }
void FiltMaxImg(const Img& in, const int k_width, const int k_height, const int channel, Img& out) { const int width = in.width(); const int height = in.height(); const int num_channel = in.channel(); assert(num_channel > channel); out.Reshape(width, height, 1); const double* in_data = in.data(); double* out_data = out.mutable_data(); for(int h = 0; h < height; h++) { for (int w = 0; w < width; w++) { int w_start = w - ((k_width) / 2); int h_start = h - ((k_height) / 2); int kw_start = 0; int kh_start = 0; int kw_end = k_width; int kh_end = k_height; double max_value = -MAX_DOUBLE; for (int i = kh_start; i < kh_end; i++ ) { for (int j = kw_start; j < kw_end; j++) { int w_temp = w_start + j; int h_temp = h_start + i; if (w_temp >=0 && w_temp < width && h_temp >= 0 && h_temp < height) { max_value = std::max(max_value, in_data[h_temp * width + w_temp]); } } } out_data[h * width + w] = max_value; } } }
void FiltImg(const Img& in, const Img& filter, const int channel, Img& out) { const int width = in.width(); const int height = in.height(); const int num_channel = in.channel(); assert(num_channel > channel); out.Reshape(width, height, 1); const double* in_data = in.data() + channel * out.dim(); const double* filter_data = filter.data(); double* out_data = out.mutable_data(); const int k_width = filter.width(); const int k_height = filter.height(); for(int h = 0; h < height; h++) { for (int w = 0; w < width; w++) { int w_start = w - ((k_width) / 2); int h_start = h - ((k_height) / 2); int kw_start = 0; int kh_start = 0; int kw_end = k_width; int kh_end = k_height; double sum = 0; for (int i = kh_start; i < kh_end; i++ ) { for (int j = kw_start; j < kw_end; j++) { int w_temp = w_start + j; int h_temp = h_start + i; if (w_temp >=0 && w_temp < width && h_temp >= 0 && h_temp < height) { sum += in_data[h_temp * width + w_temp] * filter_data[i * k_width + j]; //printf("%f x %f, ", in_data[h_temp * width + w_temp], filter_data[i * k_width + j]); //printf("%d %d, \n", h_temp, w_temp); } } } out_data[h * width + w] = sum; } } }
int main(int argc, char *argv[]) { if (argc!=2 && argc!=3) { std::cerr<<"To extract a file: "<<std::endl; std::cerr<<argv[0]<<" <img> <file>"<<std::endl; std::cerr<<"To extract all files: "<<std::endl; std::cerr<<argv[0]<<" <img>"<<std::endl; return EXIT_FAILURE; } bool all_files = argc==2; std::string extract; if (!all_files) extract = argv[2]; try { std::ifstream in; in.open(argv[1], std::ios::binary); APP_ASSERT_IO_SUCCESSFUL(in,"opening IMG"); Img img; img.init(in, argv[1]); if (!all_files) { unsigned long off = img.fileOffset(extract); unsigned long sz = img.fileSize(extract); extract_file(in, extract, off, sz); return EXIT_SUCCESS; } for (size_t i=0 ; i<img.size() ; i++) { unsigned long off = img.fileOffset(i); unsigned long sz = img.fileSize(i); extract_file(in, img.fileName(i), off, sz); } return EXIT_SUCCESS; } catch (const Exception &e) { CERR << e << std::endl; return EXIT_FAILURE; } }
bool writeImage(const std::string& path, Img& img) { if (endsWith(path, ".ptx")) { // make sure it's a power of two if (!checkPowerOfTwo(img)) return 0; // write ptx face-zero image std::string error; PtexWriter* ptx = PtexWriter::open(path.c_str(), Ptex::mt_quad, img.dt, img.nchan, img.achan, 1, error); if (!ptx) { std::cerr << error << std::endl; return 0; } ptx->setBorderModes(opt.uMode, opt.vMode); // write image top-down (flipped) int rowlen = img.w * img.nchan * Ptex::DataSize(img.dt); char* toprow = (char*) img.data + (img.h-1) * rowlen; Ptex::Res res(PtexUtils::floor_log2(img.w), PtexUtils::floor_log2(img.h)); int adjfaces[4], adjedges[4]; if (opt.uMode == Ptex::m_periodic) { adjfaces[0] = 0; adjfaces[2] = 0; adjedges[0] = 2; adjedges[2] = 0; } else { adjfaces[0] = -1; adjfaces[2] = -1; adjedges[0] = 0; adjedges[2] = 0; } if (opt.vMode == Ptex::m_periodic) { adjfaces[1] = 0; adjfaces[3] = 0; adjedges[1] = 3; adjedges[3] = 1; } else { adjfaces[1] = -1; adjfaces[3] = -1; adjedges[1] = 0; adjedges[3] = 0; } Ptex::FaceInfo finfo(res, adjfaces, adjedges); ptx->writeFace(0, finfo, toprow, -rowlen); // write meta data for (std::map<std::string,std::string>::iterator iter = opt.meta.begin(), end = opt.meta.end(); iter != end; iter++) { ptx->writeMeta(iter->first.c_str(), iter->second.c_str()); } bool ok = ptx->close(error); if (!ok) { std::cerr << error << std::endl; } ptx->release(); return ok; } else { return img.save(path); } }
void analyze_srcimg() { printf("analyzing source img..."); fflush(stdout); srck = new Kcoherence<K>[srcim->w*srcim->h]; int inset = srcwrap ? 0 : Nsize; for(int j=inset;j<srcim->h-inset;j++) for(int i=inset;i<srcim->w-inset;i++) { int idx = srcim->ij_to_idx(i,j); srck[idx] = ::nn_search(srcim, i,j, Nsize, srcwrap); #if 0 printf("%d: ", idx); for(int k=0;k<srck[idx].n;k++) { printf("%d(%d)%s", srck[idx]._idx[k], srck[idx]._err[k], k==K-1?"":","); } printf("\n"); #endif } printf("done\n"); }
// blit the src as a matte void BlitMatte( Img const& srcimg, Box const& srcbox, Img& destimg, Box& destbox, PenColour const& transparentcolour, PenColour const& mattecolour ) { switch(srcimg.Fmt()) { case FMT_I8: BlitMatteI8Keyed(srcimg,srcbox,destimg,destbox,transparentcolour.idx(), mattecolour); return; case FMT_RGBX8: BlitMatteRGBX8Keyed(srcimg,srcbox,destimg,destbox,transparentcolour.rgb(), mattecolour); return; case FMT_RGBA8: BlitMatteRGBA8Keyed(srcimg,srcbox,destimg,destbox, mattecolour); return; default: assert(false); } }
// blit from an I8 source to any target, with colourkey transparency void BlitI8Keyed( Img const& srcimg, Box const& srcbox, Palette const& srcpalette, Img& destimg, Box& destbox, int transparentIdx ) { assert(srcimg.Fmt()==FMT_I8); Box destclipped( destbox ); Box srcclipped( srcbox ); clip_blit( srcimg.Bounds(), srcclipped, destimg.Bounds(), destclipped ); const int w = destclipped.w; int y; for( y=0; y<destclipped.h; ++y ) { I8 const* src = srcimg.PtrConst_I8( srcclipped.x+0, srcclipped.y+y ); switch(destimg.Fmt()) { case FMT_I8: scan_I8_I8_keyed(src, destimg.Ptr_I8(destclipped.x+0,destclipped.y+y), w, transparentIdx); break; case FMT_RGBX8: scan_I8_RGBX8_keyed(src, srcpalette, destimg.Ptr_RGBX8(destclipped.x+0,destclipped.y+y), w, transparentIdx); break; case FMT_RGBA8: scan_I8_RGBA8_keyed(src, srcpalette, destimg.Ptr_RGBA8(destclipped.x+0,destclipped.y+y), w, transparentIdx); break; default: assert(false); break; } } destbox = destclipped; }
bool readImage(const std::string& path, Img& img) { if (endsWith(path, ".ptx")) { img.path = path; // read ptx face-zero image std::string error; PtexTexture* ptx = PtexTexture::open(path.c_str(), error); if (!ptx) { std::cerr << error << std::endl; return 0; } if (ptx->numFaces() != 1) { std::cerr << "Error: Ptex file has multiple faces (not yet supported)" << std::endl; ptx->release(); return 0; } bool ok = PtexToImg(ptx, img, /*faceid*/ 0, /*flip*/ true); ptx->release(); return ok; } else { return img.load(path); } }
void Sporulation::SporeSpreadDisp(Img& S_umca, Img& S_oaks, Img& I_umca, Img& I_oaks, Img& lvtree_rast, Rtype rtype, double *weather, double scale1, int kappa, Direction wdir, double scale2,double gamma){ //unsigned seed = std::chrono::system_clock::now().time_since_epoch().count(); //std::default_random_engine generator(seed); std::cauchy_distribution<double> distribution_cauchy_one(0.0,scale1); std::cauchy_distribution<double> distribution_cauchy_two(0.0,scale2); std::bernoulli_distribution distribution_bern(gamma); std::uniform_real_distribution<double> distribution_uniform(0.0,1.0); int height = S_umca.getHeight(); int width = S_umca.getWidth(); int w_e_res = S_umca.getWEResolution(); int n_s_res = S_umca.getNSResolution(); double dist=0; double theta = 0; if(!sp){ cerr << "The spore matrix is empty!" << endl; return; } for(int i=0;i<height;i++){ for(int j=0;j<width;j++){ if(sp[i][j]>0){ for(int k=0;k<sp[i][j];k++){ // generate the distance from cauchy distribution or cauchy mixture distribution if(rtype == CAUCHY){ dist = abs(distribution_cauchy_one(generator)); }else if(rtype == CAUCHY_MIX){ if(gamma >= 1 || gamma <= 0){ cerr << "The parameter gamma must be in the range (0~1)" << endl; return; } // use bernoulli distribution to act as the sampling with prob(gamma,1-gamma) if(distribution_bern(generator)) dist = abs(distribution_cauchy_one(generator)); else dist = abs(distribution_cauchy_two(generator)); }else{ cerr << "The paramter Rtype muse be set as either CAUCHY OR CAUCHY_MIX" << endl; exit(EXIT_FAILURE); } if(wdir == NO){ kappa = 0; } theta = vonmisesvariate(wdir*PI/180,kappa); int row = i - round(dist*cos(theta) / n_s_res); int col = j + round(dist*sin(theta) / w_e_res); if(row<0 || row>=height) continue; if(col<0 || col>= width) continue; if(row == i && col == j){ if(S_umca.data[row][col] >0 || S_oaks.data[row][col] >0){ double prob = (double)(S_umca.data[row][col]+S_oaks.data[row][col]) / lvtree_rast.data[row][col]; double U = distribution_uniform(generator); prob = prob*weather[row*width+col]; // if U < prob, then one host will become infected if(U<prob){ double prob_S_umca = (double)(S_umca.data[row][col]) / ( S_umca.data[row][col]+S_oaks.data[row][col]); double prob_S_oaks = (double)(S_oaks.data[row][col]) / ( S_umca.data[row][col]+S_oaks.data[row][col]); std::bernoulli_distribution distribution_bern_prob(prob_S_umca); if(distribution_bern_prob(generator)){ I_umca.data[row][col] +=1; S_umca.data[row][col] -=1; }else{ I_oaks.data[row][col] +=1; S_oaks.data[row][col] -=1; } } } }else{ if(S_umca.data[row][col]>0){ double prob_S_umca = (double)(S_umca.data[row][col]) / lvtree_rast.data[row][col]; double U = distribution_uniform(generator); prob_S_umca *= weather[row*width+col]; if(U<prob_S_umca){ I_umca.data[row][col] +=1; S_umca.data[row][col] -=1; } } } } } } } }
float WeightedDIDCompass::computeAngle( Img *SS, Img *CV, bool useWeight ) { // Return the angle that the angle of rotation between the CV and SS by // finding the rotation of CV with the minimum difference to SS. float lowestSSD = FLT_MAX; int bestShift = 0; for ( int shift=0; shift < width; shift++ ) { ImgOps::rotate(CV, shift, &Rotated); ImgOps::sqdDiff(SS, &Rotated, &SqdDiff); if (smoothRadius > 0) ImgOps::smooth(&SqdDiff, &SqdDiffSmoothed, smoothRadius); else SqdDiffSmoothed = SqdDiff; if (useWeight) ImgOps::mult(&SqdDiffSmoothed, &FinalWeight, &SqdDiffSmoothed); float ssd = SqdDiffSmoothed.getSum(); if ( ssd < lowestSSD ) { lowestSSD = ssd; bestShift = shift; } } //if ( debug && learnIndex >= learnStart && learnIndex <= learnStop ) { if ( debug ) { Img* Temp1 = new Img(width, height); Img* Temp2 = new Img(width, height); float threshold = FinalWeight.getMax() / 4.0; Temp2 = ImgOps::threshold(&FinalWeight, threshold, Temp1); imgWindow->clear(); imgWindow->addImg("SS", *SS); imgWindow->addImg("InsWeight", InstWeight); imgWindow->addImg("FinalWeight", FinalWeight); imgWindow->addImg("Thresholded Weight", *Temp2); imgWindow->refresh(); Img* Overlay = new Img(width, height); for (int x=0; x<width; x++) { for (int y=0; y<height; y++) { if ( Temp2->get(x, y) == 1 ) Overlay->set(x, y, 1); else Overlay->set(x, y, SS->get(x,y)); } } ostringstream oss; oss << setfill('0') << setw(2); oss << learnIndex; oss << ".png"; Overlay->save("overlay" + oss.str()); FinalWeight.save("weight" + oss.str()); Temp2->save("thresholded" + oss.str()); } // A negative image rotation (rotation to the left) corresponds // to a positive angle. Hence the negative sign below. return -Angles::int2angle(bestShift, CV->getWidth()); }
void SavePNG( Img const& img, RGBx const* palette, const char* filename ) { assert(img.Format()==Img::INDEXED8BIT); // TODO: set error handler to capture error msg? FILE *fp = fopen(filename, "wb"); if (!fp) { throw Wobbly( "open failed: %s", strerror(errno) ); } png_structp png_ptr = png_create_write_struct( PNG_LIBPNG_VER_STRING, (png_voidp)0,0,0 ); if (!png_ptr) { fclose(fp); throw Wobbly( "failed writing PNG (png_create_write() failed)" ); } png_infop info_ptr = png_create_info_struct(png_ptr); if (!info_ptr) { fclose(fp); png_destroy_write_struct(&png_ptr, (png_infopp)NULL); throw Wobbly( "failed writing PNG (png_create_info_struct() failed)" ); } if (setjmp(png_jmpbuf(png_ptr))) { png_destroy_write_struct(&png_ptr, &info_ptr); fclose(fp); throw Wobbly( "failed writing PNG" ); } png_init_io(png_ptr, fp); png_set_IHDR( png_ptr, info_ptr, img.W(), img.H(), 8, PNG_COLOR_TYPE_PALETTE, PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT ); { png_color tmp_palette[256]; int i; for(i=0;i<256;++i) { tmp_palette[i].red = palette[i].r; tmp_palette[i].green = palette[i].g; tmp_palette[i].blue = palette[i].b; } png_set_PLTE( png_ptr, info_ptr, tmp_palette, 256 ); } //png_set_bKGD( png_ptr, info_ptr, 0 ); { png_bytep row_pointers[ img.H() ]; int y; for( y=0;y<img.H();++y) row_pointers[y] = (png_bytep)img.PtrConst(0,y); png_set_rows( png_ptr, info_ptr, row_pointers ); png_write_png(png_ptr, info_ptr, 0, NULL); } png_destroy_write_struct(&png_ptr, &info_ptr); fclose(fp); }
void LoadPNG( Img& img, RGBx* palette, const char* filename ) { FILE *fp = fopen(filename, "rb"); if (!fp) throw Wobbly( "open failed: %s", strerror(errno) ); unsigned char header[8]; fread( header, 1, 8, fp ); bool is_png = !png_sig_cmp( header, 0, 8 ); if( !is_png ) { fclose(fp); throw Wobbly( "Not a PNG file." ); } png_structp png_ptr = png_create_read_struct (PNG_LIBPNG_VER_STRING, (png_voidp)NULL, NULL, NULL ); if( !png_ptr ) { fclose(fp); throw Wobbly( "png_create_read_struct() failed" ); } png_infop info_ptr = png_create_info_struct(png_ptr); if (!info_ptr) { fclose(fp); png_destroy_read_struct(&png_ptr, (png_infopp)NULL, (png_infopp)NULL); throw Wobbly( "png_create_info_struct() failed" ); } png_infop end_info = png_create_info_struct(png_ptr); if (!end_info) { fclose(fp); png_destroy_read_struct(&png_ptr, &info_ptr, (png_infopp)NULL); throw Wobbly( "png_create_info_struct() failed" ); } if (setjmp(png_jmpbuf(png_ptr))) { png_destroy_read_struct(&png_ptr, &info_ptr, &end_info); fclose(fp); throw Wobbly( "error reading PNG" ); } png_init_io(png_ptr, fp); png_set_sig_bytes(png_ptr, 8); png_read_info(png_ptr, info_ptr); png_uint_32 width; png_uint_32 height; int color_type; int bit_depth; png_get_IHDR(png_ptr, info_ptr, &width, &height, &bit_depth, &color_type, NULL, NULL, NULL ); if( color_type != PNG_COLOR_TYPE_PALETTE ) { throw Wobbly( "PNG does not have a palette" ); } if (bit_depth == 16) png_set_strip_16(png_ptr); if (bit_depth < 8) png_set_packing(png_ptr); // read in the image data Img tmp( Img::INDEXED8BIT, width, height ); png_bytep row_pointers[ tmp.H() ]; int y; for( y=0;y<tmp.H();++y) row_pointers[y] = (png_bytep)tmp.Ptr(0,y); png_read_image( png_ptr, row_pointers ); img.Copy(tmp); // now read in the palette png_colorp colours; int num_colours; png_get_PLTE(png_ptr, info_ptr, &colours, &num_colours); assert( num_colours <= 256 ); int i=0; while( i<num_colours ) { png_color c = colours[i]; palette[i] = RGBx( c.red, c.green, c.blue ); ++i; } // black out any missing colours while( i<=255 ) { palette[i] = RGBx(0,0,0); ++i; } png_read_end(png_ptr, end_info); png_destroy_read_struct(&png_ptr, &info_ptr, &end_info); fclose(fp); }
void resize_clobber_image(Img& img, const typename Img::x_coord_t& width, const typename Img::y_coord_t& height) { img.recreate(width,height); }
void resize_clobber_image(Img& img, const typename Img::point_t& new_dims) { img.recreate(new_dims); }
void CGui::InitGui() { mGui = app->mGui; gcom->mGui = mGui; SliderValue::pGUI = mGui; SliderValue::bGI = &bGI; Check::pGUI = mGui; Check::bGI = &bGI; if (!mGui) return; Ogre::Timer ti; // new widgets FactoryManager::getInstance().registerFactory<MultiList2>("Widget"); FactoryManager::getInstance().registerFactory<Slider>("Widget"); // load app->vwGui = LayoutManager::getInstance().loadLayout("Editor.layout"); // wnds app->mWndMain = fWnd("MainMenuWnd"); app->mWndTrack = fWnd("TrackWnd"); app->mWndEdit = fWnd("EditorWnd"); app->mWndOpts = fWnd("OptionsWnd"); app->mWndHelp = fWnd("HelpWnd"); app->mWndPick = fWnd("PickWnd"); app->mWndCam = fWnd("CamWnd"); app->mWndCam->setPosition(0,64); app->mWndStart = fWnd("StartWnd"); app->mWndStart->setPosition(0,64); app->mWndBrush = fWnd("BrushWnd"); app->mWndBrush->setPosition(0,64); app->mWndRoadCur = fWnd("RoadCur"); app->mWndRoadCur->setPosition(0,40); app->mWndRoadStats = fWnd("RoadStats"); app->mWndRoadStats->setPosition(0,338); app->mWndFluids = fWnd("FluidsWnd"); app->mWndFluids->setPosition(0,64); app->mWndObjects= fWnd("ObjectsWnd"); app->mWndObjects->setPosition(0,64); app->mWndRivers = fWnd("RiversWnd"); app->mWndRivers->setPosition(0,64); // for find defines Btn btn, bchk; Sl* sl; SV* sv; Ck* ck; // Tabs TabPtr tab,sub; fTabW("TabWndTrack"); app->mWndTabsTrack = tab; fTabW("TabWndEdit"); app->mWndTabsEdit = tab; fTabW("TabWndOpts"); app->mWndTabsOpts = tab; fTabW("TabWndHelp"); app->mWndTabsHelp = tab; // get sub tabs vSubTabsTrack.clear(); for (size_t i=0; i < app->mWndTabsTrack->getItemCount(); ++i) { sub = (TabPtr)app->mWndTabsTrack->getItemAt(i)->findWidget("SubTab"); vSubTabsTrack.push_back(sub); } vSubTabsEdit.clear(); for (size_t i=0; i < app->mWndTabsEdit->getItemCount(); ++i) { sub = (TabPtr)app->mWndTabsEdit->getItemAt(i)->findWidget("SubTab"); vSubTabsEdit.push_back(sub); // 0 for not found } vSubTabsHelp.clear(); for (size_t i=0; i < app->mWndTabsHelp->getItemCount(); ++i) { sub = (TabPtr)app->mWndTabsHelp->getItemAt(i)->findWidget("SubTab"); vSubTabsHelp.push_back(sub); } vSubTabsOpts.clear(); for (size_t i=0; i < app->mWndTabsOpts->getItemCount(); ++i) { sub = (TabPtr)app->mWndTabsOpts->getItemAt(i)->findWidget("SubTab"); vSubTabsOpts.push_back(sub); } /// Gui common init --- gcom->InitMainMenu(); gcom->GuiInitTooltip(); gcom->GuiInitLang(); gcom->GuiInitGraphics(); gcom->InitGuiScreenRes(); //app->mWndTabs->setIndexSelected(3); //default*-- gcom->ResizeOptWnd(); //? // center mouse pos app->mCursorManager->cursorVisibilityChange(app->bGuiFocus || !app->bMoveCam); gcom->GuiCenterMouse(); // hide --- app->SetEdMode(ED_Deform); app->UpdEditWnds(); // UpdVisHit(); //after track #if 0 ///0 _tool_ fix video capture cursor imgCur = mGui->createWidget<ImageBox>("ImageBox", 100,100, 32,32, Align::Default, "Pointer"); imgCur->setImageTexture("pointer.png"); imgCur->setVisible(true); #endif // tool window texts ---------------------- int i; for (i=0; i<MAX_TXT; ++i) { String s = toStr(i); if (i<BR_TXT){ brTxt[i] = fTxt("brTxt"+s); brVal[i] = fTxt("brVal"+s); brKey[i] = fTxt("brKey"+s); } if (i<RD_TXT){ rdTxt[i] = fTxt("rdTxt"+s); rdVal[i] = fTxt("rdVal"+s); rdKey[i] = fTxt("rdKey"+s); } if (i<RDS_TXT){ rdTxtSt[i] = fTxt("rdTxtSt"+s); rdValSt[i] = fTxt("rdValSt"+s); } if (i<ST_TXT) stTxt[i] = fTxt("stTxt"+s); if (i<FL_TXT) flTxt[i] = fTxt("flTxt"+s); if (i<OBJ_TXT) objTxt[i]= fTxt("objTxt"+s); if (i<RI_TXT) riTxt[i] = fTxt("riTxt"+s); } /// brush presets o o o o o o o o ScrollView* scv = mGui->findWidget<ScrollView>("svBrushes"); int j=0, n=0; const int z = 128; for (i=0; i < app->brSetsNum; ++i,++n) { const App::BrushSet& st = app->brSets[i]; const String s = toStr(i); int x,y, xt,yt, sx, row1 = i-14; // y,x for next lines if (row1 < 0) // top row { x = 10+ i*50; y = 10; xt = x + 20; yt = y + 50; sx = 48; }else { if (st.newLine==1 && n > 0 || n > 9) { n=0; ++j; } // 1 new line x = 20+ n*70; y = 10+ j*70; xt = x + 25; yt = y + 55; sx = 64; if (st.newLine < 0) n -= st.newLine; // -1 empty x } Img img = scv->createWidget<ImageBox>("ImageBox", x,y, sx,sx, Align::Default, "brI"+s); img->eventMouseButtonClick += newDelegate(this, &CGui::btnBrushPreset); img->setUserString("tip", st.name); img->setNeedToolTip(true); img->setImageTexture("brushes.png"); img->setImageCoord(IntCoord(i%16*z,i/16*z, z,z)); if (!st.name.empty()) img->eventToolTip += newDelegate(gcom, &CGuiCom::notifyToolTip); gcom->setOrigPos(img, "EditorWnd"); Txt txt = scv->createWidget<TextBox>("TextBox", xt,yt, 40,22, Align::Default, "brT"+s); txt->setCaption(fToStr(st.Size,0,2)); int edMode = st.edMode; float fB = app->brClr[edMode][0], fG = app->brClr[edMode][1], fR = app->brClr[edMode][2]; float m = st.Size / 160.f + 0.4f; #define mul(v,m) std::min(1.f, std::max(0.f, v * m)) txt->setTextColour(Colour(mul(fB,m), mul(fG,m), mul(fR,m)) ); gcom->setOrigPos(txt, "EditorWnd"); } //scv->setCanvasSize(1020,j*90+300); /// [Settings] //------------------------------------------------------------------------ sv= &svCamSpeed; sv->Init("CamSpeed", &pSet->cam_speed, 0.1f,4.f); sv->DefaultF(0.9f); sv= &svCamInert; sv->Init("CamInert", &pSet->cam_inert, 0.f, 1.f); sv->DefaultF(0.4f); ck= &ckMinimap; ck->Init("Minimap", &pSet->trackmap); Cev(Minimap); sv= &svSizeMinimap; sv->Init("SizeMinimap", &pSet->size_minimap, 0.15f,2.f); sv->DefaultF(0.55f); Sev(SizeMinimap); sv= &svSizeRoadP; sv->Init("SizeRoadP", &pSet->road_sphr, 0.1f,12.f); sv->DefaultF(1.5f); Sev(SizeRoadP); sv= &svTerUpd; sv->Init("TerUpd", &pSet->ter_skip, 0, 20); sv->DefaultI(1); sv= &svMiniUpd; sv->Init("MiniUpd", &pSet->mini_skip, 0, 20); sv->DefaultI(4); ck= &ckWireframe; ck->Init("Wireframe", &app->mbWireFrame); Cev(Wireframe); ck= &ckCamPos; ck->Init("CamPos", &pSet->camPos); Cev(CamPos); ck= &ckInputBar; ck->Init("InputBar", &pSet->inputBar); Cev(InputBar); ck= &ckAllowSave; ck->Init("AllowSave", &pSet->allow_save); // set camera btns Btn("CamView1", btnSetCam); Btn("CamView2", btnSetCam); Btn("CamView3", btnSetCam); Btn("CamView4", btnSetCam); Btn("CamTop", btnSetCam); Btn("CamLeft", btnSetCam); Btn("CamRight", btnSetCam); Btn("CamFront", btnSetCam); Btn("CamBack", btnSetCam); // startup ck= &ckStartInMain; ck->Init("StartInMain", &pSet->startInMain); ck= &ckAutoStart; ck->Init("AutoStart", &pSet->autostart); ck= &ckEscQuits; ck->Init("EscQuits", &pSet->escquit); ck= &ckOgreDialog; ck->Init("OgreDialog", &pSet->ogre_dialog); ck= &ckMouseCapture;ck->Init("MouseCapture",&pSet->mouse_capture); /// [Sun] //---------------------------------------------------------------------------------------------- sv= &svSunPitch; sv->Init("SunPitch", &sc->ldPitch, 0.f,90.f, 1.f, 1,4); sv->DefaultF(54.f); Sev(UpdSun); sv= &svSunYaw; sv->Init("SunYaw", &sc->ldYaw, -180.f,180.f, 1.f, 1,4); sv->DefaultF(-123.f); Sev(UpdSun); sv= &svRain1Rate; sv->Init("Rain1Rate", &sc->rainEmit, 0.f,6000.f); sv->DefaultF(1000.f); sv= &svRain2Rate; sv->Init("Rain2Rate", &sc->rain2Emit, 0.f,6000.f); sv->DefaultF(1000.f); // fog sv= &svFogStart; sv->Init("FogStart", &sc->fogStart, 0.f,2000.f, 2.f, 0,3); sv->DefaultF(100.f); Sev(UpdFog); sv= &svFogEnd; sv->Init("FogEnd", &sc->fogEnd, 0.f,2000.f, 2.f, 0,3); sv->DefaultF(600.f); Sev(UpdFog); sv= &svFogHStart; sv->Init("FogHStart", &sc->fogHStart, 0.f,2000.f, 2.f, 0,3); sv->DefaultF(0.f); Sev(UpdFog); sv= &svFogHEnd; sv->Init("FogHEnd", &sc->fogHEnd, 0.f,2000.f, 2.f, 0,3); sv->DefaultF(60.f); Sev(UpdFog); sv= &svFogHeight; sv->Init("FogHeight", &sc->fogHeight, -200.f,200.f, 1.f, 1,4); sv->DefaultF(-300.f); Sev(UpdFog); sv= &svFogHDensity; sv->Init("FogHDensity", &sc->fogHDensity, 0.f,200.f, 2.f, 1,4); sv->DefaultF(60.f); Sev(UpdFog); ck= &ckFog; ck->Init("FogDisable", &pSet->bFog); Cev(Fog); ck= &ckWeather; ck->Init("WeatherDisable", &pSet->bWeather); // light Ed(LiAmb, editLiAmb); Ed(LiDiff, editLiDiff); Ed(LiSpec, editLiSpec); Ed(FogClr, editFogClr); Ed(FogClr2, editFogClr2); Ed(FogClrH, editFogClrH); clrAmb = fImg("ClrAmb"); clrDiff = fImg("ClrDiff"); clrSpec= fImg("ClrSpec"); clrTrail= fImg("ClrTrail"); clrFog = fImg("ClrFog"); clrFog2 = fImg("ClrFog2"); clrFogH= fImg("ClrFogH"); //Todo: on click event - open color dialog /// [Terrain] //------------------------------------------------------------------------ imgTexDiff = fImg("TerImgDiff"); Tab(tabsHmap, "TabHMapSize", tabHmap); sv= &svTerErrorNorm; sv->Init("TerErrorNorm", &sc->td.errorNorm, 1.5f,15.f, 1.5f,1,3); sv->DefaultF(3.f); Sev(TerErrorNorm); sv= &svTerNormScale; sv->Init("TerNormScale", &sc->td.normScale, 0.01f,3.f, 1.f, 1,3); sv->DefaultF(1.f); Sev(TerPar); sv= &svTerSpecPow; sv->Init("TerSpecPow", &sc->td.specularPow, 0.2f,128.f,2.f, 1,4); sv->DefaultF(32.f); Sev(TerPar); sv= &svTerSpecPowEm; sv->Init("TerSpecPowEm", &sc->td.specularPowEm, 0.5f,4.f, 1.f, 1,3); sv->DefaultF(2.f); Sev(TerPar); Btn("TerrainNew", btnTerrainNew); Btn("TerrainGenAdd", btnTerGenerate); Btn("TerrainGenSub", btnTerGenerate); Btn("TerrainGenMul", btnTerGenerate); Btn("TerrainHalf", btnTerrainHalf); Btn("TerrainDouble", btnTerrainDouble); Btn("TerrainMove", btnTerrainMove); /// generator . . . . . . . sv= &svTerGenScale; sv->Init("TerGenScale", &pSet->gen_scale, 0.f,160.f, 2.f, 2,4); sv->DefaultF(52.f); sv= &svTerGenOfsX; sv->Init("TerGenOfsX", &pSet->gen_ofsx, -12.f,12.f, 1.f, 3,5); sv->DefaultF(0.14f); Sev(TerGen); sv= &svTerGenOfsY; sv->Init("TerGenOfsY", &pSet->gen_ofsy, -12.f,12.f, 1.f, 3,5); sv->DefaultF(-1.54f); Sev(TerGen); sv= &svTerGenFreq; sv->Init("TerGenFreq", &pSet->gen_freq, 0.06f,3.f, 2.f, 3,5); sv->DefaultF(0.914f); Sev(TerGen); sv= &svTerGenOct; sv->Init("TerGenOct", &pSet->gen_oct, 0, 9); sv->DefaultI(4); Sev(TerGen); sv= &svTerGenPers; sv->Init("TerGenPers", &pSet->gen_persist,0.f, 0.7f, 1.f, 3,5); sv->DefaultF(0.347f); Sev(TerGen); sv= &svTerGenPow; sv->Init("TerGenPow", &pSet->gen_pow, 0.f, 6.f, 2.f, 2,4); sv->DefaultF(1.f); Sev(TerGen); sv= &svTerGenMul; sv->Init("TerGenMul", &pSet->gen_mul, 0.f, 6.f, 2.f, 2,4); sv->DefaultF(1.f); sv= &svTerGenOfsH; sv->Init("TerGenOfsH", &pSet->gen_ofsh, 0.f, 60.f, 2.f, 2,4); sv->DefaultF(0.f); sv= &svTerGenRoadSm;sv->Init("TerGenRoadSm",&pSet->gen_roadsm, 0.f, 6.f, 1.f, 2,4); sv->DefaultF(0.f); sv= &svTerGenAngMin;sv->Init("TerGenAngMin",&pSet->gen_terMinA, 0.f, 90.f, 1.f, 1,4); sv->DefaultF(0.f); sv= &svTerGenAngMax;sv->Init("TerGenAngMax",&pSet->gen_terMaxA, 0.f, 90.f, 1.f, 1,4); sv->DefaultF(90.f); sv= &svTerGenAngSm; sv->Init("TerGenAngSm", &pSet->gen_terSmA, 0.f, 90.f, 2.f, 1,4); sv->DefaultF(10.f); sv= &svTerGenHMin; sv->Init("TerGenHMin", &pSet->gen_terMinH,-150.f,150.f, 1.f, 0,1); sv->DefaultF(-300.f); sv= &svTerGenHMax; sv->Init("TerGenHMax", &pSet->gen_terMaxH,-150.f,150.f, 1.f, 0,1); sv->DefaultF( 300.f); sv= &svTerGenHSm; sv->Init("TerGenHSm", &pSet->gen_terSmH, 0.f, 100.f, 2.f, 1,4); sv->DefaultF(20.f); /// [Layers] ------------------------------------ bool b; ck= &ckTerLayOn; ck->Init("TerLayOn", &b); Cev(TerLayOn); valTerLAll = fTxt("TerLayersAll"); valTriplAll = fTxt("TerTriplAll"); Tab(tabsTerLayers, "TabTerLay", tabTerLayer); Btn("UpdateLayers", btnUpdateLayers); ck= &ckTexNormAuto; ck->Init("TexNormAuto", &bTexNormAuto); ck= &ckTerLayTripl; ck->Init("TerLayTripl", &b); Cev(TerLayTripl); ck= &ckDebugBlend; ck->Init("DebugBlend", &bDebugBlend); Cev(DebugBlend); dbgLclr = fImg("dbgTerLclr"); float f=0.f; i=0; // temp vars // ter layer sv= &svTerTriSize; sv->Init("TerTriSize", &sc->td.fTriangleSize, 0.5f,3.f, 1.f); sv->DefaultF(1.4f); Sev(TerTriSize); sv= &svTerLScale; sv->Init("TerLScale", &f, 6.0f, 72.f, 2.f); sv->DefaultF(8.f); //Sev(TerLay); // blendmap sv= &svTerLAngMin; sv->Init("TerLAngMin", &f, 0.f, 90.f, 1.f, 1,4); sv->DefaultF(0.f); Sev(TerLay); sv= &svTerLAngMax; sv->Init("TerLAngMax", &f, 0.f, 90.f, 1.f, 1,4); sv->DefaultF(90.f); Sev(TerLay); sv= &svTerLAngSm; sv->Init("TerLAngSm", &f, 0.f, 90.f, 2.f, 1,4); sv->DefaultF(20.f); Sev(TerLay); sv= &svTerLHMin; sv->Init("TerLHMin", &f,-150.f,150.f, 1.f, 0,2); sv->DefaultF(-300.f); Sev(TerLay); sv= &svTerLHMax; sv->Init("TerLHMax", &f,-150.f,150.f, 1.f, 0,2); sv->DefaultF( 300.f); Sev(TerLay); sv= &svTerLHSm; sv->Init("TerLHSm", &f, 0.f, 100.f, 2.f, 1,4); sv->DefaultF(20.f); Sev(TerLay); Btn("TerLmoveL", btnTerLmoveL); Btn("TerLmoveR", btnTerLmoveR); // noise ck= &ckTerLNOnly; ck->Init("TerLNonly", &b); Cev(TerLNOnly); sv= &svTerLNoise; sv->Init("TerLNoise", &f, 0.f,1.f); sv->DefaultF(0.f); Sev(TerLay); sv= &svTerLNprev; sv->Init("TerLNprev", &f, 0.f,1.f); sv->DefaultF(0.f); Sev(TerLay); sv= &svTerLNnext2; sv->Init("TerLNnext2", &f, 0.f,1.f); sv->DefaultF(0.f); Sev(TerLay); // noise params for (i=0; i<2; ++i) { String s = toStr(i+1); sv= &svTerLN_Freq[i]; sv->Init("TerLNFreq"+s, &f, 1.f,300.f, 2.f, 1,3); sv->DefaultF(30.f); Sev(TerLay); sv= &svTerLN_Oct[i]; sv->Init("TerLNOct" +s, &i, 1,5); sv->DefaultI(3); Sev(TerLay); sv= &svTerLN_Pers[i]; sv->Init("TerLNPers"+s, &f, 0.1f, 0.7f, 1.f, 3,5); sv->DefaultF(0.3f); Sev(TerLay); sv= &svTerLN_Pow[i]; sv->Init("TerLNPow" +s, &f, 0.2f, 8.f, 2.f); sv->DefaultF(1.f); Sev(TerLay); } // noise btns Btn("TerLNbtn1", radN1); bRn1 = btn; bRn1->setStateSelected(true); Btn("TerLNbtn2", radN2); bRn2 = btn; for (i=0; i < 15; ++i) { Btn("TerLN_"+toStr(i), btnNpreset); } Btn("TerLNrandom", btnNrandom); Btn("TerLNswap", btnNswap); // particles Ed(LDust, editLDust); Ed(LDustS, editLDust); Ed(LMud, editLDust); Ed(LSmoke, editLDust); Ed(LTrlClr, editLTrlClr); Cmb(cmbParDust, "CmbParDust", comboParDust); Cmb(cmbParMud, "CmbParMud", comboParDust); Cmb(cmbParSmoke,"CmbParSmoke",comboParDust); // surface Cmb(cmbSurface, "Surface", comboSurface); //1 txt- txtSuBumpWave = fTxt("SuBumpWave"); txtSuFrict = fTxt("SuFrict"); txtSuBumpAmp = fTxt("SuBumpAmp"); txtSurfTire = fTxt("SurfTire"); txtSuRollDrag = fTxt("SuRollDrag"); txtSurfType = fTxt("SurfType"); SldUpd_TerL(); /// [Vegetation] ------------------------------------ sv= &svGrassDens; sv->Init("GrassDens", &sc->densGrass, 0.f, 1.f, 2.f); sv->DefaultF(0.2f); sv= &svTreesDens; sv->Init("TreesDens", &sc->densTrees, 0.f, 3.f, 2.f); sv->DefaultF(0.3f); Ed(GrPage, editTrGr); Ed(GrDist, editTrGr); Ed(TrPage, editTrGr); Ed(TrDist, editTrGr); Ed(TrImpDist, editTrGr); sv= &svTrRdDist; sv->Init("TrRdDist", &sc->trRdDist, 0,6); sv->DefaultI(1); sv= &svGrDensSmooth;sv->Init("GrDensSmooth",&sc->grDensSmooth, 0,10); sv->DefaultI(3); Ed(SceneryId, editTrGr); // veget models ck= &ckPgLayOn; ck->Init("LTrEnabled", &b); Cev(PgLayOn); valLTrAll = fTxt("LTrAll"); Tab(tabsPgLayers, "LTrNumTab", tabPgLayers); Btn("UpdateVeget", btnUpdateVeget); sv= &svLTrDens; sv->Init("LTrDens", &f, 0.f, 1.f, 2.f, 3,5); sv->DefaultF(0.15f); sv= &svLTrRdDist; sv->Init("LTrRdDist", &i, 0,20); sv->DefaultI(0); sv= &svLTrRdDistMax;sv->Init("LTrRdDistMax", &i, 0,20); sv->DefaultI(20); sv= &svLTrMinSc; sv->Init("LTrMinSc", &f, 0.f,4.f, 3.f, 3,5); sv->DefaultF(0.7f); Sev(LTrSc); sv= &svLTrMaxSc; sv->Init("LTrMaxSc", &f, 0.f,4.f, 3.f, 3,5); sv->DefaultF(1.2f); Sev(LTrSc); sv= &svLTrWindFx; sv->Init("LTrWindFx", &f, 0.f,12.f, 3.f, 3,5); sv->DefaultF(0.5f); sv= &svLTrWindFy; sv->Init("LTrWindFy", &f, 0.f,0.4f, 3.f, 3,5); sv->DefaultF(0.06f); sv= &svLTrMaxTerAng;sv->Init("LTrMaxTerAng", &f, 0.f,90.f, 2.f, 1,4); sv->DefaultF(30.f); sv= &svLTrMinTerH; sv->Init("LTrMinTerH", &f,-60.f,60.f, 1.f, 1,4); sv->DefaultF(-100.f); sv= &svLTrMaxTerH; sv->Init("LTrMaxTerH", &f, 0.f,120.f, 1.f, 1,4); sv->DefaultF( 100.f); sv= &svLTrFlDepth; sv->Init("LTrFlDepth", &f, 0.f,5.f, 2.f, 1,4); sv->DefaultF(0.f); SldUpd_PgL(); // real &f set here txVCnt = fTxt("LTrInfCnt"); txVHmin = fTxt("LTrInfHmin"); txVHmax = fTxt("LTrInfHmax"); txVWmin = fTxt("LTrInfWmin"); txVWmax = fTxt("LTrInfWmax"); /// Grass ------------------------------------ Ed(GrSwayDistr, editTrGr); Ed(GrSwayLen, editTrGr); Ed(GrSwaySpd, editTrGr); imgGrass = fImg("ImgGrass"); imgGrClr = fImg("ImgGrClr"); Cmb(cmbGrassClr, "CmbGrClr", comboGrassClr); // grass channels sv= &svGrChAngMin; sv->Init("GrChMinA", &f, 0.f,90.f, 1.f, 1,4); sv->DefaultF(30.f); sv= &svGrChAngMax; sv->Init("GrChMaxA", &f, 0.f,90.f, 1.f, 1,4); sv->DefaultF(30.f); sv= &svGrChAngSm; sv->Init("GrChSmA", &f, 0.f,50.f, 2.f, 1,4); sv->DefaultF(20.f); sv= &svGrChHMin; sv->Init("GrChMinH", &f,-60.f,60.f, 1.f, 1,4); sv->DefaultF(-200.f); sv= &svGrChHMax; sv->Init("GrChMaxH", &f, 0.f,120.f, 1.f, 1,4); sv->DefaultF( 200.f); sv= &svGrChHSm; sv->Init("GrChSmH", &f, 0.f,60.f, 2.f, 1,4); sv->DefaultF(20.f); sv= &svGrChRdPow; sv->Init("GrChRdPow", &f, -8.f, 8.f, 1.f, 1,4); sv->DefaultF(0.f); // noise sv= &svGrChNoise; sv->Init("GrChNoise", &f, 0.f,2.f, 1.f, 1,4); sv->DefaultF(0.f); sv= &svGrChNfreq; sv->Init("GrChNFreq", &f, 1.f,300.f, 2.f, 1,3); sv->DefaultF(30.f); sv= &svGrChNoct; sv->Init("GrChNOct", &i, 1,5); sv->DefaultI(3); sv= &svGrChNpers; sv->Init("GrChNPers", &f, 0.1f, 0.7f, 1.f, 3,5); sv->DefaultF(0.3f); sv= &svGrChNpow; sv->Init("GrChNPow", &f, 0.2f, 8.f, 2.f); sv->DefaultF(1.f); Tab(tabsGrChan, "GrChanTab", tabGrChan); SldUpd_GrChan(); // grass layers ck= &ckGrLayOn; ck->Init("LGrEnabled", &b); Cev(GrLayOn); valLGrAll = fTxt("LGrAll"); Tab(tabsGrLayers, "LGrLayTab", tabGrLayers); Btn("UpdateGrass", btnUpdateGrass); sv= &svGrMinX; sv->Init("GrMinX", &f, 0.5f,4.f, 1.5f); sv->DefaultF(1.2f); sv= &svGrMaxX; sv->Init("GrMaxX", &f, 0.5f,4.1, 1.5f); sv->DefaultF(1.6f); sv= &svGrMinY; sv->Init("GrMinY", &f, 0.5f,4.f, 1.5f); sv->DefaultF(1.2f); sv= &svGrMaxY; sv->Init("GrMaxY", &f, 0.5f,4.f, 1.5f); sv->DefaultF(1.6f); sv= &svGrChan; sv->Init("LGrChan", &i, 0,3); sv->DefaultI(0); sv= &svLGrDens; sv->Init("LGrDens", &f, 0.001f,1.f, 2.f, 3,5); sv->DefaultF(0.22f); SldUpd_GrL(); /// [Road] ------------------------------------ sv= &svRdTcMul; sv->Init("RdTcMul", &f, 0.01f,0.3f, 1.5f, 3,5); sv->DefaultF(0.1f); sv= &svRdTcMulW; sv->Init("RdTcMulW", &f, 0.01f,0.4f, 1.5f, 3,5); sv->DefaultF(0.1f); sv= &svRdTcMulP; sv->Init("RdTcMulP", &f, 0.01f,0.3f, 1.5f, 3,5); sv->DefaultF(0.2f); sv= &svRdTcMulPW; sv->Init("RdTcMulPW", &f, 0.01f,0.4f, 1.5f, 3,5); sv->DefaultF(0.2f); sv= &svRdTcMulC; sv->Init("RdTcMulC", &f, 0.01f,0.4f, 1.5f, 3,5); sv->DefaultF(0.2f); sv= &svRdLenDim; sv->Init("RdLenDim", &f, 0.5f, 4.f, 1.5f, 2,4); sv->DefaultF(1.f); sv= &svRdWidthSteps;sv->Init("RdWidthSteps",&i, 3,16, 1.5f); sv->DefaultI(6); sv= &svRdPlsM; sv->Init("RdPlsM", &f, 1.f, 8.f, 1.5f, 1,3); sv->DefaultF(1.f); sv= &svRdPwsM; sv->Init("RdPwsM", &f, 1.f, 8.f, 1.5f, 1,3); sv->DefaultF(4.f); sv= &svRdColN; sv->Init("RdColN", &i, 3,16, 1.5f); sv->DefaultI(4); sv= &svRdColR; sv->Init("RdColR", &f, 1.0f, 6.f, 1.5f, 2,4); sv->DefaultF(2.f); sv= &svRdMergeLen; sv->Init("RdMergeLen", &f, 40.f, 2000.f, 2.f, 0,2); sv->DefaultF(400.f); sv= &svRdLodPLen; sv->Init("RdLodPLen", &f, 10.f, 160.f, 2.f, 0,2); sv->DefaultF(20.f); SldUpd_Road(); Ed(RdHeightOfs, editRoad); Ed(RdSkirtLen, editRoad); Ed(RdSkirtH, editRoad); /// [Game] ------------------------------------ sv= &svDamage; sv->Init("DamageMul", &sc->damageMul, 0.f,2.f, 1.f, 2,4); sv->DefaultF(1.f); sv= &svWind; sv->Init("WindAmt", &sc->windAmt, -6.f,6.f, 1.0f, 2,5); sv->DefaultF(0.f); sv= &svGravity; sv->Init("Gravity", &sc->gravity, 2.f,20.f, 1.5f, 2,4); sv->DefaultF(9.81f); ck= &ckDenyReversed; ck->Init("DenyReversed", &sc->denyReversed); ck= &ckTiresAsphalt; ck->Init("TiresAsphalt", &sc->asphalt); ck= &ckTerrainEmissive; ck->Init("TerrainEmissive", &sc->td.emissive); /// [Tools] ------------------------------------ Btn("TrackCopySel", btnTrkCopySel); valTrkCpySel = fTxt("TrkCopySelName"); Btn("CopySun", btnCopySun); Btn("CopyTerHmap", btnCopyTerHmap); Btn("CopyTerLayers", btnCopyTerLayers); Btn("CopyVeget", btnCopyVeget); Btn("CopyRoad", btnCopyRoad); Btn("CopyRoadPars", btnCopyRoadPars); Btn("DeleteRoad", btnDeleteRoad); Btn("DeleteFluids", btnDeleteFluids); Btn("DeleteObjects", btnDeleteObjects); sv= &svScaleAllMul; sv->Init("ScaleAllMul", &fScale, 0.5f,2.f, 1.5f); sv->DefaultF(1.f); sv= &svScaleTerHMul; sv->Init("ScaleTerHMul", &fScaleTer, 0.5f,2.f, 1.5f); sv->DefaultF(1.f); Btn("ScaleAll", btnScaleAll); Btn("ScaleTerH", btnScaleTerH); sv= &svAlignWidthAdd; sv->Init("AlignWidthAdd", &pSet->al_w_add, 0.f,20.f,1.f, 1,3); sv->DefaultF(10.f); sv= &svAlignWidthMul; sv->Init("AlignWidthMul", &pSet->al_w_mul, 1.f,4.f, 1.f, 2,4); sv->DefaultF(1.f); sv= &svAlignSmooth; sv->Init("AlignSmooth", &pSet->al_smooth, 0.f,6.f, 1.f, 1,3); sv->DefaultF(3.f); /// [Warnings] ------------------------------------ edWarn = fEd("Warnings"); txWarn = mGui->createWidget<TextBox>("TextBox", 300,20, 360,32, Align::Default, "Back"); txWarn->setTextShadow(true); txWarn->setTextShadowColour(Colour::Black); txWarn->setTextColour(Colour(1.0,0.4,0.2)); txWarn->setFontHeight(24); txWarn->setVisible(false); imgWarn = fImg("ImgWarn"); imgWarn->setVisible(false); imgInfo = fImg("ImgInfo"); ck= &ckCheckSave; ck->Init("CheckSave", &pSet->check_save); ck= &ckCheckLoad; ck->Init("CheckLoad", &pSet->check_load); Btn("CheckScId", btnCheckScId); /// Fill Combo boxes . . . . . . . //------------------------------------------------------------------------------------------------------------ //--------------------- Skies --------------------- Cmb(cmbSky, "SkyCombo", comboSky); std::string sData = PATHMANAGER::Data(); String sMat = sData +"/materials/scene/"; // path GetMaterialsMat(sMat+"sky.mat"); for (size_t i=0; i < vsMaterials.size(); ++i) { const String& s = vsMaterials[i]; if (s != "" && s != "base_sky") cmbSky->addItem(s); //LogO(s); } //--------------------- Weather --------------------- Cmb(cmbRain1, "Rain1Cmb", comboRain1); cmbRain1->addItem(""); Cmb(cmbRain2, "Rain2Cmb", comboRain2); cmbRain2->addItem(""); GetMaterials("weather.particle", true, "particle_system"); for (size_t i=0; i < vsMaterials.size(); ++i) { const String& s = vsMaterials[i]; cmbRain1->addItem(s); cmbRain2->addItem(s); } //--------------------- Terrain --------------------- Cmb(cmbTexNorm, "TexNormal", comboTexNorm); cmbTexNorm->addItem("flat_n.png"); strlist li; PATHMANAGER::DirList(sData + (pSet->tex_size > 0 ? "/terrain" : "/terrain_s"), li); for (strlist::iterator i = li.begin(); i != li.end(); ++i) { String s = *i; if (StringUtil::match(*i, "*_n.*", false)) cmbTexNorm->addItem(*i); //else //if (StringUtil::match(*i, "*_d.*", false)) //_T // cmbTexDiff->addItem(*i); } // particles GetMaterials("tires.particle", true, "particle_system"); for (size_t i=0; i < vsMaterials.size(); ++i) { const String& s = vsMaterials[i]; cmbParDust->addItem(s); cmbParMud->addItem(s); cmbParSmoke->addItem(s); } // surfaces for (size_t i=0; i < app->surfaces.size(); ++i) cmbSurface->addItem(app->surfaces[i].name); //--------------------- Grass --------------------- PATHMANAGER::DirList(sData + "/grass", li); for (strlist::iterator i = li.begin(); i != li.end(); ++i) { if (StringUtil::startsWith(*i, "grClr", false)) cmbGrassClr->addItem(*i); } //--------------------- Roads --------------------- GetMaterialsMat(sMat+"road.mat"); GetMaterialsMat(sMat+"pipe.mat",false); for (size_t i=0; i<4; ++i) { Cmb(cmbPipeMtr[i], "RdMtrP"+toStr(i+1), comboPipeMtr); if (i>0) { cmbPipeMtr[i]->addItem(""); } } Cmb(cmbRoadWMtr, "RdMtrW1", comboRoadWMtr); Cmb(cmbPipeWMtr, "RdMtrPW1", comboPipeWMtr); Cmb(cmbRoadColMtr, "RdMtrC1", comboRoadColMtr); for (size_t i=0; i < vsMaterials.size(); ++i) { String s = vsMaterials[i]; if (StringUtil::startsWith(s,"pipe") && !StringUtil::startsWith(s,"pipe_")) for (int n=0; n<4; ++n) cmbPipeMtr[n]->addItem(s); if (StringUtil::startsWith(s,"road_wall")) cmbRoadWMtr->addItem(s); if (StringUtil::startsWith(s,"pipe_wall")) cmbPipeWMtr->addItem(s); if (StringUtil::startsWith(s,"road_col")) cmbRoadColMtr->addItem(s); } //--------------------- Objects --------------------- app->vObjNames.clear(); strlist lo; PATHMANAGER::DirList(sData + "/objects", lo); for (strlist::iterator i = lo.begin(); i != lo.end(); ++i) if (StringUtil::endsWith(*i,".mesh") && !StringUtil::startsWith(*i,"sphere")) app->vObjNames.push_back((*i).substr(0,(*i).length()-5)); //no .ext objListDyn = fLi("ObjListDyn"); Lev(objListDyn, ObjsChng); objListSt = fLi("ObjListSt"); Lev(objListSt, ObjsChng); objListRck = fLi("ObjListRck"); Lev(objListRck, ObjsChng); objListBld = fLi("ObjListBld"); Lev(objListBld, ObjsChng); objPan = fWP("objPan"); for (int i=0; i < app->vObjNames.size(); ++i) { const std::string& name = app->vObjNames[i]; if (name != "sphere") { if (StringUtil::startsWith(name,"pers_",false)) objListBld->addItem("#E0E070"+name); // buildings else if (StringUtil::startsWith(name,"rock",false)||StringUtil::startsWith(name,"cave",false)) objListRck->addItem("#E0B070"+name); // rocks else if (boost::filesystem::exists(sData+"/objects/"+ name + ".bullet")) objListDyn->addItem("#A0E0FF"+name); // dynamic else objListSt->addItem("#C8C8C8"+name); } } //objList->setIndexSelected(0); //objList->findItemIndexWith(modeSel) //--------------------- Surfaces --------------------- surfList = fLi("SurfList"); Lev(surfList, Surf); for (n=0; n < 4; ++n) surfList->addItem("#80FF00"+TR("#{Layer} ")+toStr(n)); for (n=0; n < 4; ++n) surfList->addItem("#FFB020"+TR("#{Road} ")+toStr(n)); for (n=0; n < 4; ++n) surfList->addItem("#FFFF80"+TR("#{Pipe} ")+toStr(n)); surfList->setIndexSelected(0); //--------------------- Tweak --------------------- ComboBoxPtr cmbTwk; Cmb(cmbTwk, "TweakMtr", comboTweakMtr); GetMaterialsMat(sData +"/materials/water.mat"); GetMaterialsMat(sMat+"pipe.mat",false); GetMaterialsMat(sMat+"road.mat",false); GetMaterialsMat(sMat+"objects_static.mat",false); cmbTwk->addItem(""); for (size_t i=0; i < vsMaterials.size(); ++i) { String s = vsMaterials[i]; cmbTwk->addItem(s); } cmbTwk->setIndexSelected( cmbTwk->findItemIndexWith(pSet->tweak_mtr) ); /// [Pick window] ///------------------------------------------------------------------------------------------------------------ // Pick btns Btn("PickTex", btnPickTex); btn->eventMouseWheel += newDelegate(this, &CGui::wheelTex); btnTexDiff = btn; Btn("PickGrass", btnPickGrass); btn->eventMouseWheel += newDelegate(this, &CGui::wheelGrs); btnGrassMtr = btn; Btn("PickVeget", btnPickVeget); btn->eventMouseWheel += newDelegate(this, &CGui::wheelVeg); btnVeget = btn; for (n=0; n < 4; ++n) { Btn("RdMtr"+toStr(n+1), btnPickRoad); btnRoad[n] = btn; } ck= &ckPickSetPar; ck->Init("PickSetPar", &pSet->pick_setpar); panPick = fWP("PanelPick"); // todo: pick filter sceneries .. //const char sc[17]="TJSFGWIADCVUMOER"; //chk "Pick"+sc[i] //"PickRadAll" "PickRadCur" "PickRadFilter" /// Tex Diff -------- Mli2 lp; int l; lp = app->mWndPick->createWidget<MultiList2>("MultiListBox",8,8,400,800, Align::Left | Align::VStretch); liTex = lp; lp->eventListChangePosition += newDelegate(this, &CGui::listPickTex); lp->setColour(Colour(0.8,0.9,0.7)); lp->setInheritsAlpha(false); lp->removeAllColumns(); lp->removeAllItems(); lp->addColumn("#90C0F0", 25); //+TR("#{Scenery}") lp->addColumn("#E0FFE0"+TR("#{Diffuse}"), 160); ///pick dim lp->addColumn("#80FF80"+TR("#{Scale}"), 40); //lp->addColumn("#80FF80/", 40); lp->addColumn("#80FF80|"/*+TR("#{HighestSlopes}")*/, 27); lp->addColumn(" ", 20); liPickW[0] = 280; for (i=0; i < data->pre->ter.size(); ++i) { const PTer& t = data->pre->ter[i]; String c = gcom->scnClr[gcom->scnN[t.sc]]; if (c.empty()) c = "#000000"; lp->addItem(c+ t.sc, 0); l = lp->getItemCount()-1; lp->setSubItemNameAt(1,l, c+ t.texFile.substr(0, t.texFile.length()-2)); // no _d lp->setSubItemNameAt(2,l, c+ fToStr( t.tiling, 0,2)); //1,3 //lp->setSubItemNameAt(3,l, c+ fToStr( t.angMin, 0,2)); lp->setSubItemNameAt(3,l, c+ (t.triplanar?"1":"0")); } /// Grass -------- lp = app->mWndPick->createWidget<MultiList2>("MultiListBox",8,8,400,800, Align::Left | Align::VStretch); liGrs = lp; lp->eventListChangePosition += newDelegate(this, &CGui::listPickGrs); lp->setColour(Colour(0.7,0.9,0.7)); lp->setInheritsAlpha(false); lp->removeAllColumns(); lp->removeAllItems(); lp->addColumn("#90C0F0", 25); lp->addColumn("#E0FFE0"+TR("#{GrMaterial}"), 152); //lp->addColumn("#E0FFE0"+TR("#{GrColorMap}"), 120); lp->addColumn(" ", 20); liPickW[1] = 205; for (i=0; i < data->pre->gr.size(); ++i) { const PGrass& t = data->pre->gr[i]; String c = gcom->scnClr[gcom->scnN[t.sc]]; if (c.empty()) c = "#000000"; lp->addItem(c+ t.sc, 0); l = lp->getItemCount()-1; lp->setSubItemNameAt(1,l, c+ t.mtr); //lp->setSubItemNameAt(2,l, c+ t.clr.substr(5)); } /// Veget -------- lp = app->mWndPick->createWidget<MultiList2>("MultiListBox",8,8,400,800, Align::Left | Align::VStretch); liVeg = lp; lp->eventListChangePosition += newDelegate(this, &CGui::listPickVeg); lp->setColour(Colour(0.7,0.9,0.9)); lp->setInheritsAlpha(false); lp->removeAllColumns(); lp->removeAllItems(); lp->addColumn("#90C0F0", 25); lp->addColumn("#E0FFE0"+TR("#{Model}"), 157); lp->addColumn("#80E0E0"+TR("#{MaxScale}"), 40); lp->addColumn("#80E080/"/*+TR("#{AngleMax}")*/, 30); lp->addColumn(" ", 20); liPickW[2] = 280; for (i=0; i < data->pre->veg.size(); ++i) { const PVeget& t = data->pre->veg[i]; String c = gcom->scnClr[gcom->scnN[t.sc]]; if (c.empty()) c = "#000000"; lp->addItem(c+ t.sc, 0); l = lp->getItemCount()-1; lp->setSubItemNameAt(1,l, c+ t.name); //lp->setSubItemNameAt(2,l, c+ fToStr( t.minScale, 1,3)); lp->setSubItemNameAt(2,l, c+ fToStr( t.maxScale, 1,3)); lp->setSubItemNameAt(3,l, c+ fToStr( t.maxTerAng, 0,2)); } /// Road -------- lp = app->mWndPick->createWidget<MultiList2>("MultiListBox",8,8,400,800, Align::Left | Align::VStretch); liRd = lp; lp->eventListChangePosition += newDelegate(this, &CGui::listPickRd); lp->setColour(Colour(0.9,0.8,0.7)); lp->setInheritsAlpha(false); lp->removeAllColumns(); lp->removeAllItems(); lp->addColumn("#90C0F0", 25); lp->addColumn("#FFE0D0"+TR("#{GrMaterial}"), 157); lp->addColumn("#80E0E0"+TR("#{Surface}"), 80); lp->addColumn(" ", 20); liPickW[3] = 280; lp->addItem("#102030J", 0); lp->setSubItemNameAt(1,0, "#102030"); // "" for (i=0; i < data->pre->rd.size(); ++i) { const PRoad& t = data->pre->rd[i]; String c = gcom->scnClr[gcom->scnN[t.sc]]; if (c.empty()) c = "#000000"; lp->addItem(c+ t.sc, 0); l = lp->getItemCount()-1; lp->setSubItemNameAt(1,l, c+ t.mtr); String su = t.surfName; if (su.substr(0,4)=="road") su = su.substr(4, su.length()); lp->setSubItemNameAt(2,l, c+ su); } // todo: sort,filter pick lists.. //lp->mSortColumnIndex = pSet->tracks_sort; //lp->mSortUp = pSet->tracks_sortup; //TrackListUpd(true); //upd //listTrackChng(trkList,0); /// [Track] //------------------------------------------------------------------------ gcom->sListTrack = pSet->gui.track; //! set last gcom->bListTrackU = pSet->gui.track_user; sCopyTrack = ""; //! none bCopyTrackU = 0; // text desc Edt(gcom->trkDesc[0], "TrackDesc", editTrkDesc); trkName = fEd("TrackName"); if (trkName) trkName->setCaption(pSet->gui.track); gcom->GuiInitTrack(); // btn new, rename, delete Btn("TrackNew", btnTrackNew); Btn("TrackRename", btnTrackRename); Btn("TrackDelete", btnTrackDel); // load = new game for (int i=1; i<=2; ++i) { Btn("NewGame"+toStr(i), btnNewGame); } CreateGUITweakMtr(); /// 3d view [] (veget models, objects) //-------------------------------------------- //rndCanvas = mGUI->findWidget<Canvas>("CanVeget"); //? viewCanvas = app->mWndEdit->createWidget<Canvas>("Canvas", GetViewSize(), Align::Stretch); viewCanvas->setInheritsAlpha(false); viewCanvas->setPointer("hand"); viewCanvas->setVisible(false); viewBox->setCanvas(viewCanvas); viewBox->setBackgroundColour(Colour(0.32,0.35,0.37,0.7)); viewBox->setAutoRotation(true); viewBox->setMouseRotation(true); bGI = true; // gui inited, gui events can now save vals LogO(String("::: Time Init Gui: ") + fToStr(ti.getMilliseconds(),0,3) + " ms"); }
void CGui::InitGui() { mGui = app->mGui; gcom->mGui = mGui; Check::pGUI = mGui; SliderValue::pGUI = mGui; Check::bGI = &bGI; SliderValue::bGI = &bGI; popup->mGui = mGui; popup->mPlatform = app->mPlatform; if (!mGui) return; Ogre::Timer ti; int i; // new widgets FactoryManager::getInstance().registerFactory<MultiList2>("Widget"); FactoryManager::getInstance().registerFactory<Slider>("Widget"); // load app->vwGui = LayoutManager::getInstance().loadLayout("Game.layout"); // wnds app->mWndMain = fWnd("MainMenuWnd"); app->mWndGame = fWnd("GameWnd"); app->mWndReplays = fWnd("ReplaysWnd"); app->mWndHelp = fWnd("HelpWnd"); app->mWndOpts = fWnd("OptionsWnd"); app->mWndChampStage = fWnd("WndChampStage"); app->mWndChampStage->setVisible(false); app->mWndChampEnd = fWnd("WndChampEnd"); app->mWndChampEnd->setVisible(false); app->mWndChallStage = fWnd("WndChallStage"); app->mWndChallStage->setVisible(false); app->mWndChallEnd = fWnd("WndChallEnd"); app->mWndChallEnd->setVisible(false); app->mWndNetEnd = fWnd("WndNetEnd"); app->mWndNetEnd->setVisible(false); app->mWndTweak = fWnd("WndTweak"); app->mWndTweak->setVisible(false); app->mWndTweak->setPosition(0,40); // for find defines Btn btn, bchk; Cmb cmb; Slider* sl; SV* sv; Ck* ck; // Tabs Tab tab,sub; fTabW("TabWndGame"); app->mWndTabsGame = tab; fTabW("TabWndReplays"); app->mWndTabsRpl = tab; fTabW("TabWndHelp"); app->mWndTabsHelp = tab; fTabW("TabWndOptions"); app->mWndTabsOpts = tab; // get sub tabs vSubTabsGame.clear(); for (i=0; i < app->mWndTabsGame->getItemCount(); ++i) { // todo: startsWith("SubTab").. sub = (Tab)app->mWndTabsGame->getItemAt(i)->findWidget( i==TAB_Champs ? "ChampType" : (i==TAB_Multi ? "tabsNet" : "tabPlayer") ); vSubTabsGame.push_back(sub); // 0 for not found } vSubTabsOpts.clear(); for (i=0; i < app->mWndTabsOpts->getItemCount(); ++i) { sub = (Tab)app->mWndTabsOpts->getItemAt(i)->findWidget( i==TABo_Input ? "InputTab" : "SubTab"); vSubTabsOpts.push_back(sub); } if (pSet->inMenu > MNU_Single && pSet->inMenu <= MNU_Challenge) app->mWndTabsGame->setIndexSelected(TAB_Champs); app->mWndRpl = fWnd("RplWnd"); /// Gui common init --- gcom->InitMainMenu(); gcom->GuiInitTooltip(); gcom->GuiInitLang(); gcom->GuiInitGraphics(); gcom->InitGuiScreenRes(); loadReadme = true; toggleGui(false); app->updMouse(); gcom->bnQuit->setVisible(app->isFocGui); /// Sliders //------------------------------------------------------------------------ // Hud view sizes ---- sv= &svSizeGaug; sv->Init("SizeGaug", &pSet->size_gauges, 0.1f, 0.3f, 1.f, 3,4); sv->DefaultF(0.19f); Sev(HudSize); sv= &svTypeGaug; sv->Init("TypeGaug", &pSet->gauges_type, 0, 5); sv->DefaultI(5); Sev(HudCreate); //sv= &svLayoutGaug; sv->Init("LayoutGaug", &pSet->gauges_layout, 0, 2); sv->DefaultI(1); Sev(HudCreate); sv= &svSizeMinimap; sv->Init("SizeMinimap", &pSet->size_minimap, 0.05f, 0.3f, 1.f, 3,4); sv->DefaultF(0.165f); Sev(HudSize); sv= &svZoomMinimap; sv->Init("ZoomMinimap", &pSet->zoom_minimap, 0.9f, 4.f, 1.f, 2,4); sv->DefaultF(1.6f); Sev(HudSize); sv= &svSizeArrow; sv->Init("SizeArrow", &pSet->size_arrow, 0.1f, 0.5f, 1.f, 3,4); sv->DefaultF(0.26f); Sev(SizeArrow); Slv(CountdownTime, pSet->gui.pre_time / 0.5f /10.f); sl->mfDefault = 4.f /10.f; // graphs valGraphsType = fTxt("GraphsTypeVal"); Cmb(cmb, "CmbGraphsType", comboGraphs); cmbGraphs = cmb; if (cmb) { cmb->removeAllItems(); for (i=0; i < Gh_ALL; ++i) cmb->addItem(csGraphNames[i]); cmb->setIndexSelected(pSet->graphs_type); } valGraphsType->setCaption(toStr(pSet->graphs_type)); // Options ---- sv= &svParticles; sv->Init("Particles", &pSet->particles_len, 0.f, 4.f, 2.f); sv->DefaultF(1.5f); sv= &svTrails; sv->Init("Trails", &pSet->trails_len, 0.f, 4.f, 2.f); sv->DefaultF(3.f); // reflection sv= &svReflSkip; sv->Init("ReflSkip", &pSet->refl_skip, 0,1000, 2.f); sv->DefaultI(0); sv= &svReflFaces; sv->Init("ReflFaces", &pSet->refl_faces, 1,6); sv->DefaultI(1); sv= &svReflSize; for (i=0; i < ciShadowSizesNum; ++i) sv->strMap[i] = toStr(ciShadowSizesA[i]); sv->Init("ReflSize", &pSet->refl_size, 0,ciShadowSizesNum-1); sv->DefaultI(1.5f); sv= &svReflDist; sv->Init("ReflDist", &pSet->refl_dist, 20.f,1500.f, 2.f, 0,4, 1.f," m"); Sev(ReflDist); sv->DefaultF(300.f); sv= &svReflMode; sv->strMap[0] = TR("#{ReflMode_static}"); sv->strMap[1] = TR("#{ReflMode_single}"); sv->strMap[2] = TR("#{ReflMode_full}"); sv->Init("ReflMode", &pSet->refl_mode, 0,2); Sev(ReflMode); sv->DefaultI(1); // Sound sv= &svVolMaster; sv->Init("VolMaster", &pSet->vol_master, 0.f, 1.6f); sv->DefaultF(0.80f); Sev(VolMaster); sv= &svVolEngine; sv->Init("VolEngine", &pSet->vol_engine, 0.f, 1.4f); sv->DefaultF(0.56f); sv= &svVolTires; sv->Init("VolTires", &pSet->vol_tires, 0.f, 1.4f); sv->DefaultF(0.80f); sv= &svVolSusp; sv->Init("VolSusp", &pSet->vol_susp, 0.f, 1.4f); sv->DefaultF(0.714f); sv= &svVolEnv; sv->Init("VolEnv", &pSet->vol_env, 0.f, 1.4f); sv->DefaultF(0.928f); sv= &svVolFlSplash; sv->Init("VolFlSplash", &pSet->vol_fl_splash, 0.f, 1.4f); sv->DefaultF(0.80f); sv= &svVolFlCont; sv->Init("VolFlCont", &pSet->vol_fl_cont, 0.f, 1.4f); sv->DefaultF(0.878f); sv= &svVolCarCrash; sv->Init("VolCarCrash", &pSet->vol_car_crash, 0.f, 1.4f); sv->DefaultF(0.703f); sv= &svVolCarScrap; sv->Init("VolCarScrap", &pSet->vol_car_scrap, 0.f, 1.4f); sv->DefaultF(1.00f); // car color float f; // temp sv= &svCarClrH; sv->Init("CarClrH", &f, 0.f,1.f); Sev(CarClr); sv= &svCarClrS; sv->Init("CarClrS", &f, 0.f,1.f); Sev(CarClr); sv= &svCarClrV; sv->Init("CarClrV", &f, 0.f,1.f); Sev(CarClr); sv= &svCarClrGloss; sv->Init("CarClrGloss", &f, 0.f,1.f, 1.6f); Sev(CarClr); sv= &svCarClrRefl; sv->Init("CarClrRefl", &f, 0.f,1.4f); Sev(CarClr); UpdCarClrSld(); /// Checks //------------------------------------------------------------------------ ck= &ckReverse; ck->Init("ReverseOn", &pSet->gui.trackreverse); Cev(Reverse); // Options ---- ck= &ckParticles; ck->Init("ParticlesOn", &pSet->particles); Cev(ParTrl); ck= &ckTrails; ck->Init("TrailsOn", &pSet->trails); Cev(ParTrl); // Hud ---- ck= &ckDigits; ck->Init("Digits", &pSet->show_digits); Cev(HudShow); ck= &ckGauges; ck->Init("Gauges", &pSet->show_gauges); Cev(HudShow); ck= &ckArrow; ck->Init("Arrow", &pSet->check_arrow); Cev(Arrow); ck= &ckBeam; ck->Init("ChkBeam", &pSet->check_beam); Cev(Beam); // minimap ck= &ckMinimap; ck->Init("Minimap", &pSet->trackmap); Cev(Minimap); ck= &ckMiniZoom; ck->Init("MiniZoom", &pSet->mini_zoomed); Cev(MiniUpd); ck= &ckMiniRot; ck->Init("MiniRot", &pSet->mini_rotated); ck= &ckMiniTer; ck->Init("MiniTer", &pSet->mini_terrain); Cev(MiniUpd); ck= &ckMiniBorder; ck->Init("MiniBorder", &pSet->mini_border); Cev(MiniUpd); // camera ck= &ckCamInfo; ck->Init("CamInfo", &pSet->show_cam); Cev(HudShow); ck= &ckCamTilt; ck->Init("CamTilt", &pSet->cam_tilt); ck= &ckCamLoop; ck->Init("CamLoop", &pSet->cam_loop_chng); ck= &ckCamBnc; ck->Init("CamBounce", &pSet->cam_bounce); sv= &svCamBnc; sv->Init("CamBnc", &pSet->cam_bnc_mul, 0.f, 2.f); sv= &svFov; sv->Init("Fov", &pSet->fov_min, 50.f, 180.f, 1.f, 1,4); sv->DefaultF(90.f); sv= &svFovMax; sv->Init("FovMax", &pSet->fov_max, 50.f, 180.f, 1.f, 1,4); sv->DefaultF(120.f); sv= &svFovSm; sv->Init("FovSm", &pSet->fov_smooth, 0.f, 15.f, 1.5f); sv->DefaultF(5.f); // times, opp ck= &ckTimes; ck->Init("Times", &pSet->show_times); Cev(HudShow); ck= &ckOpponents; ck->Init("Opponents", &pSet->show_opponents); Cev(HudShow); ck= &ckOppSort; ck->Init("OppSort", &pSet->opplist_sort); // dbg,other ck= &ckFps; ck->Init("Fps", &pSet->show_fps); app->bckFps->setVisible(pSet->show_fps); ck= &ckWireframe; ck->Init("Wireframe", &app->mbWireFrame); Cev(Wireframe); ck= &ckProfilerTxt; ck->Init("ProfilerTxt", &pSet->profilerTxt); ck= &ckBulletDebug; ck->Init("BulletDebug", &pSet->bltDebug); ck= &ckBltProfTxt; ck->Init("BltProfTxt", &pSet->bltProfilerTxt); ck= &ckCarDbgBars; ck->Init("CarDbgBars", &pSet->car_dbgbars); Cev(HudShow); ck= &ckCarDbgTxt; ck->Init("CarDbgTxt", &pSet->car_dbgtxt); Cev(HudShow); ck= &ckCarDbgSurf; ck->Init("CarDbgSurf", &pSet->car_dbgsurf); Cev(HudShow); ck= &ckTireVis; ck->Init("CarTireVis", &pSet->car_tirevis); Cev(HudCreate); ck= &ckGraphs; ck->Init("Graphs", &pSet->show_graphs); Cev(Graphs); sv= &svDbgTxtClr; sv->Init("DbgTxtClr", &pSet->car_dbgtxtclr, 0, 1); sv= &svDbgTxtCnt; sv->Init("DbgTxtCnt", &pSet->car_dbgtxtcnt, 0, 8); // car setup todo: for each player .. Chk("CarABS", chkAbs, pSet->abs[0]); bchAbs = bchk; Chk("CarTCS", chkTcs, pSet->tcs[0]); bchTcs = bchk; ck= &ckCarGear; ck->Init("CarGear", &pSet->autoshift); Cev(Gear); ck= &ckCarRear; ck->Init("CarRear", &pSet->autorear); Cev(Gear); ck= &ckCarRearInv; ck->Init("CarRearThrInv",&pSet->rear_inv); Cev(Gear); TabPtr tTires = fTab("tabCarTires"); Tev(tTires, TireSet); sv= &svSSSEffect; sv->Init("SSSEffect", &f, 0.f, 1.f); sv= &svSSSVelFactor; sv->Init("SSSVelFactor", &f, 0.f, 2.f); sv= &svSteerRangeSurf; sv->Init("SteerRangeSurf", &f, 0.3f, 1.3f); sv= &svSteerRangeSim; sv->Init("SteerRangeSim", &f, 0.3f, 1.3f); Btn("SSSReset", btnSSSReset); Btn("SteerReset", btnSteerReset); SldUpd_TireSet(); // game ------------------------------------------------------------ ck= &ckVegetCollis; ck->Init("VegetCollis", &pSet->gui.collis_veget); ck= &ckCarCollis; ck->Init("CarCollis", &pSet->gui.collis_cars); ck= &ckRoadWCollis; ck->Init("RoadWCollis", &pSet->gui.collis_roadw); ck= &ckDynamicObjs; ck->Init("DynamicObjects", &pSet->gui.dyn_objects); Cmb(cmb, "CmbBoost", comboBoost); cmbBoost = cmb; cmb->removeAllItems(); cmb->addItem(TR("#{Never}")); cmb->addItem(TR("#{FuelLap}")); cmb->addItem(TR("#{FuelTime}")); cmb->addItem(TR("#{Always}")); cmb->setIndexSelected(pSet->gui.boost_type); Cmb(cmb, "CmbFlip", comboFlip); cmbFlip = cmb; cmb->removeAllItems(); cmb->addItem(TR("#{Never}")); cmb->addItem(TR("#{FuelBoost}")); cmb->addItem(TR("#{Always}")); cmb->setIndexSelected(pSet->gui.flip_type); Cmb(cmb, "CmbDamage", comboDamage); cmbDamage = cmb; cmb->removeAllItems(); cmb->addItem(TR("#{None}")); cmb->addItem(TR("#{Reduced}")); cmb->addItem(TR("#{Normal}")); cmb->setIndexSelected(pSet->gui.damage_type); Cmb(cmb, "CmbRewind", comboRewind); cmbRewind = cmb; cmb->removeAllItems(); cmb->addItem(TR("#{None}")); cmb->addItem(TR("#{Always}")); //cmb->addItem(TR("#{FuelLap}")); cmb->addItem(TR("#{FuelTime}")); cmb->setIndexSelected(pSet->gui.rewind_type); sv= &svDamageDec; sv->Init("DamageDec", &pSet->gui.damage_dec, 0.f, 100.f, 1.f, 0,1, 1.f, " %"); sv= &svBmin; sv->Init("Bmin", &pSet->gui.boost_min, 0.f, 10.f,1.f, 1,3); sv->DefaultF(2.f); sv= &svBmax; sv->Init("Bmax", &pSet->gui.boost_max, 2.f, 20.f,1.f, 1,3); sv->DefaultF(6.f); sv= &svBpow; sv->Init("Bpow", &pSet->gui.boost_power, 0.f, 2.5f,1.f, 1,3); sv->DefaultF(1.f); sv= &svBperKm; sv->Init("BperKm", &pSet->gui.boost_per_km, 0.f, 4.f, 1.f, 1,3); sv->DefaultF(1.f); sv= &svBaddSec; sv->Init("BaddSec", &pSet->gui.boost_add_sec, 0.f, 1.f, 1.f, 2,4); sv->DefaultF(0.1f); // split Btn("btnPlayers1", btnNumPlayers); Btn("btnPlayers2", btnNumPlayers); Btn("btnPlayers3", btnNumPlayers); Btn("btnPlayers4", btnNumPlayers); ck= &ckSplitVert; ck->Init("chkSplitVertically", &pSet->split_vertically); Chk("chkStartOrderRev", chkStartOrd, pSet->gui.start_order); valLocPlayers = fTxt("valLocPlayers"); if (valLocPlayers) valLocPlayers->setCaption(toStr(pSet->gui.local_players)); // sim mode radio Btn("SimModeEasy", radSimEasy); bRsimEasy = btn; btn->setStateSelected(pSet->gui.sim_mode == "easy"); Btn("SimModeNorm", radSimNorm); bRsimNorm = btn; btn->setStateSelected(pSet->gui.sim_mode == "normal"); Btn("SimModeHard", radSimHard); bRsimHard = btn; btn->setStateSelected(pSet->gui.sim_mode == "hard"); // kmh/mph radio Btn("kmh", radKmh); bRkmh = btn; bRkmh->setStateSelected(!pSet->show_mph); Btn("mph", radMph); bRmph = btn; bRmph->setStateSelected( pSet->show_mph); // startup ck= &ckStartInMain; ck->Init("StartInMain", &pSet->startInMain); ck= &ckAutoStart; ck->Init("AutoStart", &pSet->autostart); ck= &ckEscQuits; ck->Init("EscQuits", &pSet->escquit); ck= &ckOgreDialog; ck->Init("OgreDialog", &pSet->ogre_dialog); ck= &ckMouseCapture;ck->Init("MouseCapture",&pSet->mouse_capture); ck= &ckBltLines; ck->Init("BltLines", &pSet->bltLines); ck= &ckShowPics; ck->Init("ShowPictures",&pSet->loadingbackground); Chk("MultiThread", chkMultiThread, pSet->multi_thr > 0); ck= &ckDevKeys; ck->Init("DevKeys", &pSet->dev_keys); // effects ck= &ckAllEffects; ck->Init("AllEffects", &pSet->all_effects); Cev(AllEffects); ck= &ckBoostFOV; ck->Init("BoostFOV", &pSet->boost_fov); ck= &ckBloom; ck->Init("Bloom", &pSet->bloom); Cev(EffUpd); sv= &svBloomInt; sv->Init("BloomInt", &pSet->bloom_int); sv->DefaultF(0.13f); sv= &svBloomOrig; sv->Init("BloomOrig", &pSet->bloom_orig); sv->DefaultF(0.91f); ck= &ckBlur; ck->Init("MotionBlur", &pSet->blur); Cev(EffUpdShd); sv= &svBlurIntens; sv->Init("BlurIntens", &pSet->blur_int); sv->DefaultF(0.4f); ck= &ckSSAO; ck->Init("SSAO", &pSet->ssao); Cev(EffUpdShd); ck= &ckSoftPar; ck->Init("SoftParticles",&pSet->softparticles); Cev(EffUpdShd); ck= &ckGodRays; ck->Init("GodRays", &pSet->godrays); Cev(EffUpdShd); ck= &ckDoF; ck->Init("DepthOfField",&pSet->dof); Cev(EffUpdShd); sv= &svDofFocus; sv->Init("DofFocus", &pSet->dof_focus, 0.f, 2000.f, 2.f, 0,3); sv->DefaultF(100.f); sv= &svDofFar; sv->Init("DofFar", &pSet->dof_far, 0.f, 2000.f, 2.f, 0,4); sv->DefaultF(1000.f); // hdr ck= &ckHDR; ck->Init("HDR", &pSet->hdr); Cev(EffUpd); sv= &svHDRParam1; sv->Init("HDRParam1", &pSet->hdrParam1); sv->DefaultF(0.62f); sv= &svHDRParam2; sv->Init("HDRParam2", &pSet->hdrParam2, 0.f, 1.f, 2.f); sv->DefaultF(0.10f); sv= &svHDRParam3; sv->Init("HDRParam3", &pSet->hdrParam3); sv->DefaultF(0.79f); sv= &svHDRAdaptScale; sv->Init("HDRAdaptScale", &pSet->hdrAdaptationScale, 0.f, 1.f, 2.f); sv->DefaultF(0.10f); sv= &svHDRBloomInt; sv->Init("HDRBloomInt", &pSet->hdrBloomint); sv->DefaultF(0.81f); sv= &svHDRBloomOrig; sv->Init("HDRBloomOrig", &pSet->hdrBloomorig); sv->DefaultF(0.34f); sv= &svHDRVignRadius; sv->Init("HDRVignRadius", &pSet->vignRadius, 0.f, 10.f); sv->DefaultF(2.85f); sv= &svHDRVignDark; sv->Init("HDRVignDark", &pSet->vignDarkness); sv->DefaultF(0.34f); // replays ------------------------------------------------------------ Btn("RplLoad", btnRplLoad); Btn("RplSave", btnRplSave); Btn("RplDelete", btnRplDelete); Btn("RplRename", btnRplRename); // settings ck= &ckRplAutoRec; ck->Init("RplChkAutoRec", &app->bRplRec); ck= &ckRplBestOnly; ck->Init("RplChkBestOnly", &pSet->rpl_bestonly); ck= &ckRplGhost; ck->Init("RplChkGhost", &pSet->rpl_ghost); ck= &ckRplParticles; ck->Init("RplChkParticles", &pSet->rpl_ghostpar); ck= &ckRplRewind; ck->Init("RplChkRewind", &pSet->rpl_ghostrewind); ck= &ckRplGhostOther; ck->Init("RplChkGhostOther",&pSet->rpl_ghostother); ck= &ckRplTrackGhost; ck->Init("RplChkTrackGhost",&pSet->rpl_trackghost); Slv(RplNumViewports, (pSet->rpl_numViews-1) / 3.f); // radios, filter ck= &ckRplGhosts; ck->Init("RplBtnGhosts", &pSet->rpl_listghosts); Cev(RplGhosts); Btn("RplBtnAll", btnRplAll); rbRplAll = btn; Btn("RplBtnCur", btnRplCur); rbRplCur = btn; btn = pSet->rpl_listview == 0 ? rbRplAll : rbRplCur; if (btn) btn->setStateSelected(true); if (app->mWndRpl) { // replay controls Btn("RplToStart", btnRplToStart); Btn("RplToEnd", btnRplToEnd) Btn("RplPlay", btnRplPlay); btRplPl = btn; btn = fBtn("RplBack"); btn->eventMouseButtonPressed += newDelegate(this, &CGui::btnRplBackDn); btn->eventMouseButtonReleased += newDelegate(this, &CGui::btnRplBackUp); btn = fBtn("RplForward"); btn->eventMouseButtonPressed += newDelegate(this, &CGui::btnRplFwdDn); btn->eventMouseButtonReleased += newDelegate(this, &CGui::btnRplFwdUp); // info slRplPos = (Slider*)app->mWndRpl->findWidget("RplSlider"); if (slRplPos) slRplPos->eventValueChanged += newDelegate(this, &CGui::slRplPosEv); valRplPerc = fTxt("RplPercent"); valRplCur = fTxt("RplTimeCur"); valRplLen = fTxt("RplTimeLen"); } // text desc, stats valRplName = fTxt("RplName"); valRplName2 = fTxt("RplName2"); valRplInfo = fTxt("RplInfo"); valRplInfo2 = fTxt("RplInfo2"); edRplName = fEd("RplNameEdit"); //edRplDesc = fEd("RplDesc"); rplList = fLi("RplList"); Lev(rplList, RplChng); updReplaysList(); /// Car //------------------------------------------------------------ const int clrBtn = 30; Real hsv[clrBtn][5] = { // color buttons hue,sat,val, gloss,refl {0.05,0.64,0.27, 0.10,0.9}, {0.00,0.97,0.90, 0.3, 1.2}, // cherry, red {0.91,1.00,1.00, 0.5, 1.0}, {0.86,1.00,0.97, 0.8, 0.6}, // orange, yellow {0.75,0.95,0.90, 1.0, 0.4}, {0.70,1.00,0.70, 0.03,1.3}, // lime, green {0.54,0.88,0.60, 0.7, 0.85},{0.51,0.90,0.50, 0.1, 0.7}, // cyan {0.41,0.34,0.30, 0.01,0.3}, {0.43,0.58,0.23, 0.1, 1.0}, // dark-cyan //{0.45,0.54,0.37, 0.5,1.0}, {0.37,0.78,0.21, 0.34,0.5}, {0.35,0.70,0.40, 0.5, 1.0}, {0.38,0.97,0.52, 0.5, 1.0}, // dark-blue {0.44,0.90,0.71, 1.0, 1.1}, {0.47,0.80,0.80, 0.2, 0.9}, // sky-blue {0.50,0.33,0.90, 0.9, 1.0}, {0.42,0.20,0.94, 0.5, 0.4}, // sky-white {0.63,0.21,0.62, 0.1, 1.2}, {0.80,0.52,0.32, 0.1, 0.6}, {0.62,0.74,0.12, 0.8, 0.7}, // olive- {0.28,0.00,0.12, 0.09,0.0}, {0.28,0.00,0.07, 0.14,0.84}, // black {0.83,0.00,0.20, 0.0, 0.8}, {0.41,0.00,0.86, 0.15,0.37}, // silver,white {0.83,0.31,0.31, 0.0, 0.6}, {0.91,0.40,0.37, 0.0, 1.0}, {0.20,0.40,0.37, 0.05,1.0}, // orng-white- {0.24,0.90,0.26, 0.04,0.8}, {0.28,0.57,0.17, 0.3, 1.0}, {0.27,0.38,0.23, 0.03,0.6}, // dark violet }; for (i=0; i < clrBtn; ++i) { Img img = fImg("carClr"+toStr(i)); Real h = hsv[i][0], s = hsv[i][1], v = hsv[i][2], g = hsv[i][3], r = hsv[i][4]; ColourValue c; c.setHSB(1.f-h, s, v); img->setColour(Colour(c.r,c.g,c.b)); img->eventMouseButtonClick += newDelegate(this, &CGui::imgBtnCarClr); img->setUserString("s", toStr(s)); img->setUserString("h", toStr(h)); img->setUserString("v", toStr(v)); img->setUserString("g", toStr(g)); img->setUserString("r", toStr(r)); } Btn("CarClrRandom", btnCarClrRandom); sv= &svNumLaps; sv->Init("NumLaps", &pSet->gui.num_laps, 1,10, 1.3f); sv->DefaultI(2); txCarStatsTxt = fTxt("CarStatsTxt"); txCarSpeed = fTxt("CarSpeed"); txCarStatsVals = fTxt("CarStatsVals"); txCarType = fTxt("CarType"); txCarAuthor = fTxt("CarAuthor"); txTrackAuthor = fTxt("TrackAuthor"); TabPtr tPlr = fTab("tabPlayer"); Tev(tPlr, Player); Btn("btnPlayers1", btnNumPlayers); Btn("btnPlayers2", btnNumPlayers); Btn("btnPlayers3", btnNumPlayers); Btn("btnPlayers4", btnNumPlayers); ck= &ckSplitVert; ck->Init("chkSplitVertically", &pSet->split_vertically); /// Multiplayer //------------------------------------------------------------------------ tabsNet = fTab("tabsNet"); //TabItem* t1 = tabsNet->getItemAt(0); //t1->setEnabled(0); //int num = tabsNet ? tabsNet->getItemCount() : 0; //tabsNet->setIndexSelected( (tabsNet->getIndexSelected() - 1 + num) % num ); // server, games listServers = fMli("MListServers"); int c=0; Mli ml = listServers; ml->addColumn("#C0FFC0"+TR("#{Game name}"), 160); ++c; ml->addColumn("#50FF50"+TR("#{Track}"), 120); ++c; ml->addColumn("#80FFC0"+TR("#{Laps}"), 60); ++c; ml->addColumn("#FFFF00"+TR("#{Players}"), 60); ++c; ml->addColumn("#80FFFF"+TR("#{Collis.}"), 70); ++c; ml->addColumn("#A0D0FF"+TR("#{Simulation}"), 80); ++c; ml->addColumn("#A0D0FF"+TR("#{Boost}"), 90); ++c; ml->addColumn("#FF6060"+TR("#{Locked}"), 60); iColLock = c; ++c; ml->addColumn("#FF9000"+TR("#{NetHost}"), 140); iColHost = c; ++c; ml->addColumn("#FFB000"+TR("#{NetPort}"), 80); iColPort = c; ++c; Btn("btnNetRefresh",evBtnNetRefresh); btnNetRefresh = btn; Btn("btnNetJoin", evBtnNetJoin); btnNetJoin = btn; Btn("btnNetCreate", evBtnNetCreate); btnNetCreate = btn; Btn("btnNetDirect", evBtnNetDirect); btnNetDirect = btn; // game, players Edt(edNetGameName, "edNetGameName", evEdNetGameName); edNetGameName->setCaption(pSet->netGameName); valNetPassword = fTxt("valNetPassword"); Edt(edNetPassword, "edNetPassword", evEdNetPassword); listPlayers = fMli("MListPlayers"); ml = listPlayers; ml->addColumn("#80C0FF"+TR("#{Player}"), 140); ml->addColumn("#F08080"+TR("#{Car}"), 60); ml->addColumn("#C0C060"+TR("#{Peers}"), 60); ml->addColumn("#60F0F0"+TR("#{Ping}"), 60); ml->addColumn("#40F040"+TR("#{NetReady}"), 60); Btn("btnNetReady", evBtnNetReady); btnNetReady = btn; Btn("btnNetLeave", evBtnNetLeave); btnNetLeave = btn; // panels to hide tabs panNetServer = fWP("panelNetServer"); panNetServer->setVisible(false); panNetGame = fWP("panelNetGame"); panNetGame->setVisible(true); // chat edNetChat = fEd("edNetChat"); // chat area edNetChatMsg = fEd("edNetChatMsg"); // user text // track,game text valNetGameInfo = fTxt("valNetGameInfo"); // settings Edt(edNetNick, "edNetNick", evEdNetNick); edNetNick->setCaption( pSet->nickname); Edt(edNetServerIP, "edNetServerIP", evEdNetServerIP); edNetServerIP->setCaption( pSet->master_server_address); Edt(edNetServerPort,"edNetServerPort", evEdNetServerPort); edNetServerPort->setCaption(toStr(pSet->master_server_port)); Edt(edNetLocalPort, "edNetLocalPort", evEdNetLocalPort); edNetLocalPort->setCaption( toStr(pSet->local_port)); // quick help text ---- Ed edHelp = fEd("QuickHelpText"); String s = TR("#{QuickHelpText}"); s = StringUtil::replaceAll(s, "@", "\n"); edHelp->setCaption(s); // user dir Ed edUserDir = fEd("EdUserDir"); edUserDir->setCaption(PATHMANAGER::UserConfigDir()); /// graphs ---- sv= &svTC_r; sv->Init("TC_r", &pSet->tc_r, 0.5f, 2.f, 1.5f, 1,4); sv->DefaultF(1.f); sv= &svTC_xr; sv->Init("TC_xr", &pSet->tc_xr, 0.f, 5.f, 1.5f, 1,4); sv->DefaultF(1.f); sv= &svTE_yf; sv->Init("TE_yf", &pSet->te_yf, 5000.f, 10000.f, 1.f, 0,4); sv->DefaultF(7000.f); sv= &svTE_xfx; sv->Init("TE_xfx", &pSet->te_xfx, 4.f, 42.f, 2.f, 1,4); sv->DefaultF(12.f); sv= &svTE_xfy; sv->Init("TE_xfy", &pSet->te_xfy, 90.f, 560.f, 2.f, 0,3); sv->DefaultF(160.f); sv= &svTE_xpow; sv->Init("TE_xpow", &pSet->te_xf_pow, 1.f, 2.f, 1.f, 1,3); sv->DefaultF(1.f); /// tweak car //------------------------------------------------------------ for (i=0; i < ciEdCar; ++i) edCar[i] = fEd("EdCar"+toStr(i)); edPerfTest = fEd("TweakPerfTest"); tabEdCar = fTab("TabEdCar"); Tev(tabEdCar, CarEdChng); tabEdCar->setIndexSelected(pSet->car_ed_tab); tabTweak = fTab("TabTweak"); /**/tabTweak->setIndexSelected(1); txtTweakPath = fTxt("TweakPath"); Btn("TweakCarSave", btnTweakCarSave); edTweakCol = fEd("TweakEditCol"); txtTweakPathCol = fTxt("TweakPathCol"); Btn("TweakColSave", btnTweakColSave); /// tweak tires ---- Btn("TweakTireSave", btnTweakTireSave); txtTweakTire = fTxt("TweakTireTxtSaved"); Edt(edTweakTireSet, "TweakTireSet", editTweakTireSet); liTwkTiresUser = fLi("TweakTiresUser"); Lev(liTwkTiresUser, TwkTiresUser); liTwkTiresOrig = fLi("TweakTiresOrig"); Lev(liTwkTiresOrig, TwkTiresOrig); Btn("TweakTireLoad", btnTweakTireLoad); Btn("TweakTireLoadRef", btnTweakTireLoadRef); /// tweak surfaces ---- liTwkSurfaces = fLi("TweakSurfaces"); Lev(liTwkSurfaces, TwkSurfaces); //<Widget type="ComboBox" name="TweakSurface"> Btn("TweakSurfPickWh", btnTwkSurfPick); sv= &svSuFrict; sv->Init("SuFrict", &f, 0.f, 1.5f, 1.0f, 2,4); sv->DefaultF(0.65f); sv= &svSuFrictX; sv->Init("SuFrictX", &f, 0.f, 1.5f, 1.0f, 2,4); sv->DefaultF(1.f); sv= &svSuFrictY; sv->Init("SuFrictY", &f, 0.f, 1.5f, 1.0f, 2,4); sv->DefaultF(1.f); sv= &svSuBumpWave; sv->Init("SuBumpWave", &f, 0.f, 50.f, 1.2f, 1,4); sv->DefaultF(20.f); sv= &svSuBumpAmp; sv->Init("SuBumpAmp", &f, 0.f, 0.4f, 1.0f, 2,4); sv->DefaultF(0.15f); sv= &svSuBumpWave2; sv->Init("SuBumpWave2", &f, 0.f, 50.f, 1.2f, 1,4); sv->DefaultF(20.f); sv= &svSuBumpAmp2; sv->Init("SuBumpAmp2", &f, 0.f, 0.4f, 1.0f, 2,4); sv->DefaultF(0.15f); sv= &svSuRollDrag; sv->Init("SuRollDrag", &f, 0.f, 200.f, 2.f, 0,3); sv->DefaultF(60.f); sv= &svSuRollRes; sv->Init("SuRollRes", &f, 0.f, 200.f, 2.f, 0,3); sv->DefaultF(1.f); //TODO: <Widget type="Button" name="TweakSurfSave"> Cmb(cmb, "CmbSuTire", comboSurfTire); cmbSurfTire = cmb; Cmb(cmb, "CmbSuType", comboSurfType); cmbSurfType = cmb; cmb->removeAllItems(); for (i=0; i < TRACKSURFACE::NumTypes; ++i) cmb->addItem(csTRKsurf[i]); /// input tab ------- InitInputGui(); /// cars list //------------------------------------------------------------------------ Tbi carTab = fTbi("TabCar"); Mli2 li = carTab->createWidget<MultiList2>("MultiListBox",16,48,200,110, Align::Left | Align::VStretch); li->setColour(Colour(0.7,0.85,1.0)); li->removeAllColumns(); int n=0; li->addColumn("#FF8888"+TR("#{Car}"), colCar[n++]); li->addColumn("#FFC080"+TR("#{CarSpeed}"), colCar[n++]); li->addColumn("#B0B8C0"+TR("#{CarYear}"), colCar[n++]); li->addColumn("#C0C0E0"+TR("#{CarType}"), colCar[n++]); li->addColumn(" ", colCar[n++]); carList = li; FillCarList(); //once li->mSortColumnIndex = pSet->cars_sort; li->mSortUp = pSet->cars_sortup; Lev(carList, CarChng); CarListUpd(false); //upd sListCar = pSet->gui.car[0]; imgCar = fImg("CarImg"); carDesc = fEd("CarDesc"); listCarChng(carList,0); /// tracks list, text, chg btn //------------------------------------------------------------------------ gcom->trkDesc[0] = fEd("TrackDesc"); gcom->sListTrack = pSet->gui.track; gcom->GuiInitTrack(); Ed ed; Edt(ed,"RplFind",edRplFind); // netw Tbi trkTab = fTbi("TabTrack"); trkTab->setColour(Colour(0.8f,0.96f,1.f)); const IntCoord& tc = trkTab->getCoord(); WP wp = trkTab->createWidget<Widget>( "PanelSkin", 0,0,tc.width*0.66f,tc.height, Align::Default/*, "Popup", "panelNetTrack"*/); wp->setColour(Colour(0.8f,0.96f,1.f)); wp->setAlpha(0.8f); wp->setVisible(false); panNetTrack = wp; //<UserString key="RelativeTo" value="OptionsWnd"/> // new game for (i=1; i<=3; ++i) { Btn("NewGame"+toStr(i), btnNewGame); if (i==2) btNewGameCar = btn; } // championships //------------------------------------------------------------------------ // track stats 2nd set gcom->trkDesc[1] = fEd("TrackDesc2"); valTrkNet = fTxt("TrackText"); // preview images gcom->imgPrv[1] = fImg("TrackImg2"); gcom->imgPrv[1]->setImageTexture("PrvView"); gcom->imgTer[1] = fImg("TrkTerImg2"); gcom->imgTer[1]->setImageTexture("PrvTer"); gcom->imgMini[1] = fImg("TrackMap2"); gcom->imgMini[1]->setImageTexture("PrvRoad"); gcom->initMiniPos(1); // track stats text int st = gcom->StTrk; for (i=0; i < st; ++i) gcom->stTrk[1][i] = fTxt("2st"+toStr(i)); for (i=0; i < 4; ++i) gcom->imStTrk[1][i] = fImg("2ist"+toStr(i)); for (i=0; i < gcom->InfTrk; ++i) { gcom->infTrk[1][i] = fTxt("2ti"+toStr(i)); gcom->imInfTrk[1][i] = fImg("2iti"+toStr(i)); } edChInfo = fEd("ChampInfo"); if (edChInfo) edChInfo->setVisible(pSet->champ_info); Btn("btnChampInfo",btnChampInfo); panCh = fWP("panCh"); txtCh = fTxt("txtChDetail"); valCh = fTxt("valChDetail"); for (i=0; i<3; ++i) { String s = toStr(i); txtChP[i] = fTxt("txtChP"+s); valChP[i] = fTxt("valChP"+s); } edChDesc = fEd("ChampDescr"); // Champs list ------------- Tbi trktab = fTbi("TabChamps"); li = trktab->createWidget<MultiList2>("MultiListBox",0,0,400,300, Align::Left | Align::VStretch); Lev(li, ChampChng); li->setVisible(false); li->removeAllColumns(); c=0; li->addColumn("#80A080N", colCh[c++]); li->addColumn(TR("#40F040#{Name}"), colCh[c++]); li->addColumn(TR("#F0F040#{Difficulty}"), colCh[c++]); li->addColumn(TR("#80F0C0#{Stages}"), colCh[c++]); li->addColumn(TR("#80E0FF#{Time} #{TimeMS}"), colCh[c++]); li->addColumn(TR("#D0C0FF#{Progress}"), colCh[c++]); li->addColumn(TR("#F0E0F0#{Score}"), colCh[c++]); li->addColumn(" ", colCh[c++]); liChamps = li; // Challs list ------------- li = trktab->createWidget<MultiList2>("MultiListBox",0,0,400,300, Align::Left | Align::VStretch); Lev(li, ChallChng); li->setVisible(false); li->removeAllColumns(); c=0; li->addColumn("#80A080N", colChL[c++]); li->addColumn(TR("#60F060#{Name}"), colChL[c++]); li->addColumn(TR("#F0D040#{Difficulty}"), colChL[c++]); li->addColumn(TR("#F09090#{Cars}"), colChL[c++]); li->addColumn(TR("#80F0C0#{Stages}"), colChL[c++]); li->addColumn(TR("#80E0FF#{Time} m"), colChL[c++]); li->addColumn(TR("#D0C0FF#{Progress}"), colChL[c++]); li->addColumn(TR("#F0F8FF#{Prize}"), colChL[c++]); li->addColumn(TR("#F0D0F0#{Score}"), colChL[c++]); li->addColumn(" ", colChL[c++]); liChalls = li; // Stages list ------------- trktab = (TabItem*)app->mWndGame->findWidget("TabStages"); li = trktab->createWidget<MultiList2>("MultiListBox",0,0,400,300, Align::Left | Align::VStretch); li->setColour(Colour(0.7,0.73,0.76)); Lev(li, StageChng); li->setVisible(false); li->removeAllColumns(); c=0; li->addColumn("#80A080N", colSt[c++]); li->addColumn(TR("#50F050#{Track}"), colSt[c++]); li->addColumn(TR("#80FF80#{Scenery}"), colSt[c++]); li->addColumn(TR("#F0F040#{Difficulty}"), colSt[c++]); li->addColumn(TR("#60E0A0#{Laps}"), colSt[c++]); li->addColumn(TR("#80E0FF#{Time} #{TimeMS}"), colSt[c++]); li->addColumn(TR("#F0E0F0#{Score}"), colSt[c++]); li->addColumn(" ", colSt[c++]); liStages = li; updChampListDim(); ChampsListUpdate(); listChampChng(liChamps, liChamps->getIndexSelected()); ChallsListUpdate(); listChallChng(liChalls, liChalls->getIndexSelected()); // tabs tabTut = fTab("TutType"); Tev(tabTut, TutType); tabTut->setIndexSelected(pSet->tut_type); tabChamp = fTab("ChampType"); Tev(tabChamp, ChampType); tabChamp->setIndexSelected(pSet->champ_type); tabChall = fTab("ChallType"); Tev(tabChall, ChallType); tabChall->setIndexSelected(pSet->chall_type); imgTut = fImg("imgTut"); imgChamp = fImg("imgChamp"); imgChall = fImg("imgChall"); Btn("btnTutStart", btnChampStart); btStTut = btn; Btn("btnChampStart",btnChampStart); btStChamp = btn; Btn("btnChallStart",btnChallStart); btStChall = btn; Btn("btnChRestart", btnChRestart); btChRestart = btn; // ch other ck= &ckChampRev; ck->Init("ChampRev", &pSet->gui.champ_rev); Cev(ChampRev); Btn("btnChampStageBack", btnChampStageBack); Btn("btnChampStageStart",btnChampStageStart); btChampStage = btn; Btn("btnChampEndClose", btnChampEndClose); Btn("btnChallStageBack", btnChallStageBack); Btn("btnChallStageStart",btnChallStageStart); btChallStage = btn; Btn("btnChallEndClose", btnChallEndClose); Btn("btnStageNext", btnStageNext); Btn("btnStagePrev", btnStagePrev); valStageNum = fTxt("StageNum"); edChampStage = fEd("ChampStageText"); edChampEnd = fEd("ChampEndText"); edChallStage = fEd("ChallStageText"); edChallEnd = fEd("ChallEndText"); // stage prv imgChampStage = fImg("ChampStageImg"); imgChampStage->setImageTexture("PrvStCh"); imgChallStage = fImg("ChallStageImg"); imgChallStage->setImageTexture("PrvStCh"); imgChampEndCup = fImg("ChampEndImgCup"); txChampEndF = fTxt("ChampEndFinished"); imgChallFail = fImg("ChallEndImgFail"); txChallEndF = fTxt("ChallEndFinished"); imgChallCup = fImg("ChallEndImgCup"); txChallEndC = fTxt("ChallEndCongrats"); UpdChampTabVis(); // netw end list ------ Btn("btnNetEndClose", btnNetEndClose); li = app->mWndNetEnd->createWidget<MultiList2>("MultiListBox",4,42,632,360, Align::Left | Align::VStretch); li->setInheritsAlpha(false); li->setColour(Colour(0.8,0.9,1,1)); li->removeAllColumns(); li->addColumn("", 40); //N li->addColumn(TR("#{TBPlace}"), 60); li->addColumn(TR("#{NetNickname}"), 180); li->addColumn(TR("#{TBTime}"), 120); li->addColumn(TR("#{TBBest}"), 120); li->addColumn(TR("#{TBLap}"), 60); liNetEnd = li; bGI = true; // gui inited, gui events can now save vals LogO(String("::: Time Init Gui: ") + fToStr(ti.getMilliseconds(),0,3) + " ms"); }
VectorImgFilter::AutoImg VectorImgFilter::selectLowLines(const Img &vi) { throw Maps::Exception("VectorImgFilter::selectLowLines(): not implemented"); AutoImg aImg( new VectorImg( vi.linesCnt() ) ); return aImg; };