delay(000); last problem in my project. need help!

Hi all,
My Sunroof controller project is almost done. The only thing I still need to solve is that if the pushbutton is pressed and outpin1/2 is HIGH, it remains HIGH unless you press it again. It should go LOW after some time (say 30sec) IF the pushbutton was not pressed earlier. As you know, (delay) won't work because it prevents turning outpin LOW before the 30sec pass.
I tried to get help from (blink without delay), but failed! :frowning:

Could anyone take a look at the Code (which is part of longer one) and add what's needed for solving the problem?

your help would be much appreciated!

int inPin2 = 2; // the number of the input pin
int outPin1 = 6; // the number of the output1 pin
int outPin2 = 7; // the number of the output2 pin
int state2; // the current state of the output2 pin
int reading2; // the current reading from the input pin2
int previous2 = HIGH; // the previous reading from the input pin2
long time = 0; // the last time the output pin was toggled
long debounce = 200; // the debounce time, increase if the output flickers
int pressCount1 = 1; 
long previousMillis1 = 0;   
long interval = 1000;

void setup()
{
pinMode(inPin2, INPUT);
pinMode(outPin1, OUTPUT);
pinMode(outPin2, OUTPUT);
}

void loop()
{
  {
  reading2 = digitalRead(inPin2);
if (reading2 == HIGH && previous2 == LOW && millis() - time > debounce) 
{
state2 = !state2; // Toggle the state
pressCount1++;
time = millis();
switch(pressCount1%4)
 {
      case 0:
digitalWrite(outPin1, LOW);       // it might be already on by another pushbutton. so must goes off
digitalWrite(outPin2, LOW);       // it might be already on by another pushbutton. so must goes off
delay(200);                       //wait for this time
digitalWrite(outPin1, HIGH);        // Turn on  pin1
        break;
      case 1:
digitalWrite(outPin1, LOW);       // Turn off  pin1
          break;
      case 2:
digitalWrite(outPin1, LOW);       // it might be already on by another pushbutton. so must goes off
digitalWrite(outPin2, LOW);       // it might be already on by another pushbutton. so must goes off
delay(200);                       //wait for this time
digitalWrite(outPin2, HIGH);        // Turn on  pin2
        break;
      case 3:
digitalWrite(outPin2, LOW);       // Turn off  pin2
        break;
    }
  }
  previous2 = reading2;
  } 
  }

Just put millis() when the button changed to high on a var and at the end of the loop() do a if var / 30000 then change button state to low.